Skip to content

Commit

Permalink
Merge pull request #86 from bryanedds/development
Browse files Browse the repository at this point in the history
Better NuEdit closing behavior.

Former-commit-id: 273d8bf
  • Loading branch information
bryanedds committed Sep 21, 2015
2 parents 13b312f + a34f570 commit a6855d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Nu/Nu/NuEdit/Interactive.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

open System
open System.IO
open System.Windows.Forms
open FSharpx
open SDL2
open OpenTK
Expand All @@ -32,9 +33,14 @@ Directory.SetCurrentDirectory ^ __SOURCE_DIRECTORY__ + "../bin/Debug"
// decide on a target directory and plugin
let (targetDir, plugin) = NuEdit.selectTargetDirAndMakeNuPlugin ()

// initialize NuEdit's dependencies
// initialize NuEdit's form
let form = NuEdit.createForm ()
form.Closing.Add (fun args -> args.Cancel <- true) // disable exiting
form.Closing.Add (fun args ->
if not args.Cancel then
MessageBox.Show ("Cannot close NuEdit when running from F# Interactive.", "Cannot Close NuEdit") |> ignore
args.Cancel <- true)

// initialize sdl dependencies using the form as its rendering surface
let sdlDeps = NuEdit.attemptMakeSdlDeps form |> Either.getRightValue

// make world ready for use in NuEdit (could instead use NuEdit.attemptMakeWorld if less flexibility is needed)
Expand Down
6 changes: 6 additions & 0 deletions Nu/Nu/NuEdit/NuEditModules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,11 @@ module NuEdit =
refreshTreeView form world
world)

let private handleFormClosing (_ : NuEditForm) (args : CancelEventArgs) =
match MessageBox.Show ("Are you sure you want to close NuEdit?", "Close NuEdit", MessageBoxButtons.YesNo) with
| DialogResult.No -> args.Cancel <- true
| _ -> ()

let private updateEntityDrag (form : NuEditForm) world =
if not ^ canEditWithMouse form world then
match (World.getUserState world).DragEntityState with
Expand Down Expand Up @@ -671,6 +676,7 @@ module NuEdit =
form.reloadAssetsButton.Click.Add (handleFormReloadAssets form)
form.reloadOverlaysButton.Click.Add (handleFormReloadOverlays form)
form.groupTabs.Selected.Add (handleFormGroupTabSelected form)
form.Closing.Add (handleFormClosing form)
form.Show ()
form

Expand Down

0 comments on commit a6855d7

Please sign in to comment.