Skip to content

Commit

Permalink
Beta Build 4 Update
Browse files Browse the repository at this point in the history
Beta Build 4 update:

* Added grid overlay button on the controls bar
* Added FOV slider back in the Settings menu. (You're welcome dbp)
* The program will now detect level ids that might not be normally used.
These are added as "Extra Levels" at the bottom of the select level
list.
* The "Select Level" window should no longer be resizable.
* Fixed a bug with loading segment 0x2 in roms that use shygoo's more
letters patch
* Fixed a bug with RGBA16 encoding

Changes by aglab2:
* Added a bunch of sanity checks in the code to improve rom
compatibility and reduce crashing.

No SM64 ROM Manager support yet. Maybe in the next build.
  • Loading branch information
DavidSM64 committed Jul 11, 2018
1 parent 4cfbc19 commit 8593164
Show file tree
Hide file tree
Showing 14 changed files with 657 additions and 316 deletions.
14 changes: 8 additions & 6 deletions Quad64.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@
<ApplicationIcon>icon_KtQ_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="OpenTK">
<HintPath>packages\OpenTK.2.0.0\lib\net20\OpenTK.dll</HintPath>
<Reference Include="OpenTK, Version=2.0.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenTK.3.0.0\lib\net20\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.GLControl, Version=1.1.0.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
<HintPath>packages\OpenTK.GLControl.1.1.2349.61993\lib\NET40\OpenTK.GLControl.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\OpenTK.GLControl.3.0.0\lib\net20\OpenTK.GLControl.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
4 changes: 2 additions & 2 deletions packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net4" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net4" />
<package id="OpenTK" version="2.0.0" targetFramework="net45" />
<package id="OpenTK.GLControl" version="1.1.2349.61993" targetFramework="net40" />
<package id="OpenTK.GLControl" version="1.1.2349.61993" targetFramework="net4" />
</packages>
330 changes: 121 additions & 209 deletions src/Forms/MainForm.Designer.cs

Large diffs are not rendered by default.

191 changes: 110 additions & 81 deletions src/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ partial class MainForm : Form
MultiselectTreeView treeView1;
readonly System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer();
bool isMouseDown = false, isShiftDown = false, isControlDown = false, moveState = false;
bool gridEnabled = false;
static Level level;
float FOV = 1.048f;


public Level getLevelData { get { return level; } }

public object SettingsForms { get; private set; }
Expand Down Expand Up @@ -80,15 +80,20 @@ public MainForm()
glControl1.CreateControl();
SettingsFile.LoadGlobalSettings("default");
glControl1.MouseWheel += new MouseEventHandler(glControl1_Wheel);
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, (float)glControl1.Width / (float)glControl1.Height, 100f, 100000f);
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(
Globals.FOV * ((float)Math.PI / 180.0f),
(float)glControl1.Width / (float)glControl1.Height,
100f,
100000f
);
glControl1.Enabled = false;
KeyPreview = true;
treeView1.HideSelection = false;
camera.updateMatrix(ref camMtx);
myTimer.Tick += updateWASDControls;
myTimer.Interval = 10;
myTimer.Enabled = false;
//foreach(ObjectComboEntry entry in Globals.objectComboEntries) Console.WriteLine(entry.ToString());
cameraMode.SelectedIndex = 0;
}

private void loadROM(bool startingUp)
Expand Down Expand Up @@ -133,6 +138,8 @@ private void loadROM(bool startingUp)
camera.setLevel(level);
updateAreaButtons();

rom.hasLookedAtLevelIDs = true;

//stopWatch.Stop();
//Console.WriteLine("Startup time: " + stopWatch.Elapsed.Milliseconds + "ms");

Expand Down Expand Up @@ -193,20 +200,61 @@ private void refreshObjectsInList()
EndUpdate(treeView1);
}

private void drawGrid()
{
int w = glControl1.Width;
int h = glControl1.Height;

GL.Disable(EnableCap.DepthTest);

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();
GL.Ortho(0, w, h, 0, -1, 1000);

GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.PushMatrix();

GL.Color3(Color.Black);
float numberLines = (int)gridSize.Value;
float lineWidthOffset = (float)w / numberLines;
float lineHeightOffset = (float)h / numberLines;
GL.Begin(PrimitiveType.Lines);
for (int i = 0; i < numberLines; i++)
{
// draw vertical line
GL.Vertex2(lineWidthOffset * i, 0);
GL.Vertex2(lineWidthOffset * i, h);

// draw horizontal line
GL.Vertex2(0, lineHeightOffset * i);
GL.Vertex2(w, lineHeightOffset * i);
}
GL.End();

GL.PopMatrix();
GL.Enable(EnableCap.DepthTest);
}

private void glControl1_Paint(object sender, PaintEventArgs e)
{
GL.ClearColor(bgColor);
if (level != null)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);


GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref ProjMatrix);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadMatrix(ref camMtx);

//level.getCurrentArea().drawPicking();
level.getCurrentArea().drawEverything();

if (gridEnabled)
drawGrid();

glControl1.SwapBuffers();
}
}
Expand Down Expand Up @@ -432,7 +480,7 @@ private void glControl1_KeyDown(object sender, KeyEventArgs e)
private void glControl1_Load(object sender, EventArgs e)
{
GL.Enable(EnableCap.Blend);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Lequal);
Expand All @@ -451,7 +499,9 @@ private void glControl1_Resize(object sender, EventArgs e)
{
glControl1.Context.Update(glControl1.WindowInfo);
GL.Viewport(0, 0, glControl1.Width, glControl1.Height);
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(FOV, (float)glControl1.Width / (float)glControl1.Height, 100f, 100000f);
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(Globals.FOV * ((float)Math.PI / 180.0f), (float)glControl1.Width / (float)glControl1.Height, 100f, 100000f);
//ProjMatrix = Matrix4.CreateOrthographic(1000f, 1000f, 100f, 100000f);

glControl1.Invalidate();
}

Expand Down Expand Up @@ -487,6 +537,7 @@ private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
{
SettingsForm settings = new SettingsForm();
settings.ShowDialog();
updateFieldOfView();
glControl1.Invalidate();
propertyGrid1.Refresh();
glControl1.Update(); // Needed after calling propertyGrid1.Refresh();
Expand Down Expand Up @@ -805,7 +856,8 @@ private void Form1_KeyDown(object sender, KeyEventArgs e)

private void resetObjectVariables()
{
radioButton1.Checked = true;
cameraMode.SelectedIndex = 0;

treeView1.SelectedNode = null;
Globals.list_selected = -1;
Globals.item_selected = -1;
Expand All @@ -816,6 +868,7 @@ private void resetObjectVariables()
private void switchLevel(ushort levelID)
{
Level testLevel = new Level(levelID, 1);
LevelScripts.parse(ref testLevel, 0x15, 0);
//Stopwatch stopWatch = new Stopwatch();
//stopWatch.Start();
LevelScripts.parse(ref testLevel, 0x15, 0);
Expand Down Expand Up @@ -936,7 +989,6 @@ private void updateAfterSelect(TreeNode node)
Globals.isMultiSelectedFromSpecialObjects = false;
bool hasSO_8 = false, hasSO_10 = false, hasSO_12 = false;
Globals.isMultiSelectedFromBothNormalWarpsAndInstantWarps = false;
bool hasRegularWarp = false, hasInstantWarp = false;
if (Globals.list_selected == 2)
{
Object3D obj3d_0 = area.SpecialObjects[treeView1.SelectedNodes[0].Index];
Expand Down Expand Up @@ -1145,6 +1197,12 @@ private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
updateAfterSelect(e.Node);
}

void updateFieldOfView()
{
ProjMatrix = Matrix4.CreatePerspectiveFieldOfView(Globals.FOV * ((float)Math.PI / 180.0f), (float)glControl1.Width / (float)glControl1.Height, 100f, 100000f);
glControl1.Invalidate();
}

private void trackBar1_ValueChanged(object sender, EventArgs e)
{
/*
Expand Down Expand Up @@ -1300,86 +1358,52 @@ private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
e.DrawDefault = true;
}
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
camera.setCameraMode(CameraMode.ORBIT, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
camera.setCameraMode(CameraMode.FLY, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}
}


private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_bottom.Checked)
{
camera.setCameraMode_LookDirection(LookDirection.BOTTOM, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}
}

private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_top.Checked)
{
camera.setCameraMode_LookDirection(LookDirection.TOP, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}
}

private void radioButton_left_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_left.Checked)
{
camera.setCameraMode_LookDirection(LookDirection.LEFT, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}
}

private void radioButton_right_CheckedChanged(object sender, EventArgs e)

private void cameraMode_SelectedIndexChanged(object sender, EventArgs e)
{
if (radioButton_right.Checked)
{
camera.setCameraMode_LookDirection(LookDirection.RIGHT, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
switch (cameraMode.SelectedIndex) {
case 0: // Fly
camera.setCameraMode(CameraMode.FLY, ref camMtx);
break;
case 1: // Orbit
camera.setCameraMode(CameraMode.ORBIT, ref camMtx);
break;
case 2: // Top
camera.setCameraMode_LookDirection(LookDirection.TOP, ref camMtx);
break;
case 3: // Bottom
camera.setCameraMode_LookDirection(LookDirection.BOTTOM, ref camMtx);
break;
case 4: // Left
camera.setCameraMode_LookDirection(LookDirection.LEFT, ref camMtx);
break;
case 5: // Right
camera.setCameraMode_LookDirection(LookDirection.RIGHT, ref camMtx);
break;
case 6: // Front
camera.setCameraMode_LookDirection(LookDirection.FRONT, ref camMtx);
break;
case 7: // Back
camera.setCameraMode_LookDirection(LookDirection.BACK, ref camMtx);
break;
}
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
}

private void radioButton_front_CheckedChanged(object sender, EventArgs e)
private void gridButton_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_front.Checked)
if (gridButton.Checked)
{
camera.setCameraMode_LookDirection(LookDirection.FRONT, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
gridSize.Enabled = true;
gridEnabled = true;
}
}

private void radioButton_back_CheckedChanged(object sender, EventArgs e)
{
if (radioButton_back.Checked)
else
{
camera.setCameraMode_LookDirection(LookDirection.BACK, ref camMtx);
camera.updateMatrix(ref camMtx);
glControl1.Invalidate();
gridSize.Enabled = false;
gridEnabled = false;
}
glControl1.Invalidate();
}

private void starAct_CheckedChanged(object sender, EventArgs e)
Expand Down Expand Up @@ -2136,6 +2160,11 @@ private void trackBar2_ValueChanged(object sender, EventArgs e)
Globals.objSpeedMultiplier = newValue / 100.0f;
}

private void gridSize_ValueChanged(object sender, EventArgs e)
{
glControl1.Invalidate();
}


private const int WM_USER = 0x0400;
private const int EM_SETEVENTMASK = (WM_USER + 69);
Expand Down
Loading

0 comments on commit 8593164

Please sign in to comment.