diff --git a/src/Forms/MainForm.cs b/src/Forms/MainForm.cs index 466951d..5637ba7 100644 --- a/src/Forms/MainForm.cs +++ b/src/Forms/MainForm.cs @@ -284,6 +284,11 @@ private void glControl1_Load(object sender, EventArgs e) GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.AlphaTest); GL.AlphaFunc(AlphaFunction.Gequal, 0.5f); + + if (Globals.doBackfaceCulling) + GL.Enable(EnableCap.CullFace); + else + GL.Disable(EnableCap.CullFace); } private void glControl1_Resize(object sender, EventArgs e) @@ -296,7 +301,9 @@ private void glControl1_Resize(object sender, EventArgs e) private void loadROMToolStripMenuItem_Click(object sender, EventArgs e) { - loadROM(false); + DialogResult saveResult = Prompts.ShowShouldSaveDialog(); + if(saveResult != DialogResult.Cancel) + loadROM(false); } private void saveROMAsToolStripMenuItem_Click(object sender, EventArgs e) @@ -526,16 +533,25 @@ private void selectLeveToolStripMenuItem_Click(object sender, EventArgs e) if (newLevel.changeLevel) { //Console.WriteLine("Changing Level to " + newLevel.levelID); - level = new Level(newLevel.levelID, 1); - camera.setCameraMode(CameraMode.FLY, ref camMtx); - camera.setLevel(level); - LevelScripts.parse(ref level, 0x15, 0); - level.sortAndAddNoModelEntries(); - level.CurrentAreaID = level.Areas[0].AreaID; - resetObjectVariables(); - refreshObjectsInList(); - glControl1.Invalidate(); - updateAreaButtons(); + Level testLevel = new Level(newLevel.levelID, 1); + LevelScripts.parse(ref testLevel, 0x15, 0); + if (testLevel.Areas.Count > 0) + { + level = testLevel; + camera.setCameraMode(CameraMode.FLY, ref camMtx); + camera.setLevel(level); + level.sortAndAddNoModelEntries(); + level.CurrentAreaID = level.Areas[0].AreaID; + resetObjectVariables(); + refreshObjectsInList(); + glControl1.Invalidate(); + updateAreaButtons(); + } + else + { + ushort id = newLevel.levelID; + MessageBox.Show("Error: No areas found in level ID: 0x" + id.ToString("X")); + } } } @@ -679,6 +695,7 @@ private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEv ((WarpInstant)warp).updateROMData(); } } + Globals.needToSave = true; } // I never want CategorizedAlphabetical, so I change it back to Categorized if detected. @@ -892,6 +909,7 @@ private void moveObj_MouseMove(object sender, MouseEventArgs e) glControl1.Invalidate(); propertyGrid1.Refresh(); glControl1.Update(); // Needed after calling propertyGrid1.Refresh(); + Globals.needToSave = true; } } } @@ -929,6 +947,7 @@ private void movObj_UpDown_MouseMove(object sender, MouseEventArgs e) propertyGrid1.Refresh(); glControl1.Update(); // Needed after calling propertyGrid1.Refresh(); moveObj_UpDown_lastMouseY = e.Y; + Globals.needToSave = true; } } } @@ -996,6 +1015,7 @@ private void rotObj_MouseMove(object sender, MouseEventArgs e) glControl1.Invalidate(); propertyGrid1.Refresh(); glControl1.Update(); // Needed after calling propertyGrid1.Refresh(); + Globals.needToSave = true; } } } @@ -1020,6 +1040,7 @@ private void dropObjectToGround() glControl1.Invalidate(); propertyGrid1.Refresh(); glControl1.Update(); // Needed after calling propertyGrid1.Refresh(); + Globals.needToSave = true; } } @@ -1035,6 +1056,15 @@ private void AreaButton_Click(object sender, EventArgs e) trySwitchArea(area); } + private void MainForm_FormClosing(object sender, FormClosingEventArgs e) + { + if (Globals.needToSave) + { + DialogResult saveResult = Prompts.ShowShouldSaveDialog(); + e.Cancel = (saveResult == DialogResult.Cancel); + } + } + bool rotObj_Yaw_mouseDown = false; int rotObj_Yaw_lastMouseY = 0; private void rotObj_Yaw_MouseDown(object sender, MouseEventArgs e) @@ -1074,6 +1104,7 @@ private void rotObj_Yaw_MouseMove(object sender, MouseEventArgs e) propertyGrid1.Refresh(); glControl1.Update(); // Needed after calling propertyGrid1.Refresh(); rotObj_Yaw_lastMouseY = e.Y; + Globals.needToSave = true; } } } diff --git a/src/LevelInfo/Object3D.cs b/src/LevelInfo/Object3D.cs index 8867010..f419c6a 100644 --- a/src/LevelInfo/Object3D.cs +++ b/src/LevelInfo/Object3D.cs @@ -251,7 +251,7 @@ public void updateROMData() else if (Globals.list_selected == 1) // Macro Object { //Console.WriteLine("Preset ID = 0x" + presetID.ToString("X")); - ushort first = (ushort)((ushort)((yRot << 9) / 2.8125f) | (presetID & 0x1FF)); + ushort first = (ushort)((((ushort)(yRot / 2.8125f) & 0x7F) << 9) | (presetID & 0x1FF)); rom.writeHalfword(romAddr, first); rom.writeHalfword(romAddr + 2, xPos); rom.writeHalfword(romAddr + 4, yPos);