HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: How to Delete FX Subgroups  (Read 708 times)

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
How to Delete FX Subgroups
« on: Mar 01, 17, 12:13:52 PM »

If you have ever worked in the FX Spec Editor you should know that you can right-click on a task to get a popup menu to delete it. But you may have noticed that it does not work for the subgroups that might be there. (The picture below shows a sample hierarchy. The main cluster with the larger FX icon is considered the "Group" and when you drag an FX box onto it that creates a subgroup.)

Anyways, looking at the code I realized the authors had put in the Delete popup menu for _FXTaskIcon controls, but not for _FXIcon controls, which are the ones used for the subgroups.

So here is what I did to the client script _FXIconClassMethods, all based on how deleting _FXTaskIcon's works:

First I added the blue code to the ActivateProxyIcon() method:

Quote
method ActivateProxyIcon(args references Class GUIMouseEvent)
  //------------------------------------------------------
  // Clicking means we have selected this icon and want to
  // display it's properties
  //------------------------------------------------------
  #if debug
    println("ActivateProxyIcon()")
  #endif
  var fxe = $FXEDIT
 
  fxe.UnSelectAllFxIconsInBrowser()
 
  if (me.IconSubject <> None)
    #if debug
      println("node = " + subj)
    #endif
    var keys = $GUI.GetKeyStates()
    var screen = GetViewPortSize()
    editor as NodeRef of Class GUIControl
    if args.rightButton
      CreateRightClickPopupMenu(me)
      me.openPopupMenu()
      args.interrupt = true
    else
if keys.altKey
      //---------------------------------------------------------------
      // This brings up josh's generic node editor which I have left in
      // only for occasional debug purposes
      // It SHOULD NOT be used for real editing
      //---------------------------------------------------------------
      editor = CreateNodeFromPrototype("NodePropertyEditor")
      editor.build = true
      editor.position.x = screen.x - editor.size.x
      editor.position.y = 0
      editor.PopulatePropertyEditor(me.IconSubject)
    else
      fxe.DisplayPropertyWindowForSubj(me.IconSubject)
    .
  else
    #if debug
      println("No subject")
    #endif
  .
.

Then I copied over these two methods from _FXTaskIconClassMethods into _FXIconClassMethods:

Quote
function CreateRightClickPopupMenu(c as NodeRef of Class GUIControl) as NodeRef of Class GUIControl
  popupMenu as NodeRef of Class GUIControl = c._addCleanEnginePopupMenu()
  popupMenu.script = SYSTEM.EXEC.THISSCRIPT
  //-------------------
  // Add the menu items
  //-------------------
  var menuitem = popupMenu._addPopupMenuItem("Delete")
  menuitem.script = SYSTEM.EXEC.THISSCRIPT

  popupMenu._autoSetPopupMenuSize()
 
  return popupMenu
.
shared function onPopupMenuSelection(myMenuItem as NodeRef of Class GUIControl)
//  println("onPopupMenuSelection menuitem: " + myMenuItem + " name: " + myMenuItem.name)
  when myMenuItem.name
    is "Delete"
      var menu = myMenuItem.rootParent()
      if menu <> None
        var icon = menu.getMyPopupOverlord()
        if icon <> None
          where icon is kindof _FxIcon
            subj as NodeRef = icon.IconSubject
            if subj <> None
              $FXEDIT.GetFxConfirmDeleteNodeDialog(subj)
            else
//              println("no subject")
            .
          .
        else
//          println("no icon")
        .
      else
//        println("no menu")
      .
    .
    default
//      println("Menuitem was: " + myMenuItem.name)
    .
  .
.

With those changes in place, you can right-click subgroups to delete them and everything inside of them.
« Last Edit: Mar 01, 17, 12:15:24 PM by FI-ScottZ »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.