Announcement

Collapse
No announcement yet.

Mouse interface does not work with Scaleform UI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Mouse interface does not work with Scaleform UI

    Hi all

    I've made an mouse interface guided by tutorial:
    http://udn.epicgames.com/Three/Devel...Interface.html

    but there is a problem-mouse cursor does not cooperate with a menu created in scaleform and imported into map :/
    Who knows how to solve that?

    #2
    Does the cursor have to exist in ScaleForm/Flash?

    Comment


      #3
      I have no idea...
      What I want to archieve is a mouse interface capable to interact both scene and scaleform UI-the first goal succedded,but for the second it's disaser,'cause the cursor is drawn under UI,and also it does not properly points the UI elements :/

      Comment


        #4
        You'll need to draw a scaleform cursor as well.

        Comment


          #5
          We do it like this, based on two solutions _h2o_ and Matt Doyle himself pointed out:

          Step 1: Create a Flash scene for the mouse cursor

          The size doesn't matter. Just do it exactly as explained by Matt Doyle in http://forums.epicgames.com/showthread.php?t=763518 Step 1. We made two things different, though:

          - Our mouse cursor movie clip is named just 'mouseCursor' instead of 'mouseCursor_mc' (we're breaking naming conventions here, huh? )
          - We did not delete the cursor movie clip form the stage.

          Step 2: Add the mouse cursor to the UDK HUD

          After having imported our Flash movie 'hwhud_mouse' to the package 'UI_HWHud', we proceeded as follows:

          Add an UnrealScript class for the mouse cursor scene. Our one looks like this:

          Code:
          // ============================================================================
          // HWGFxHUD_Mouse
          // The movie clip providing a mouse cursor that is drawn on-top of the HUD.
          //
          // Related Flash content: UDKGame/Flash/HWHud/hwhud_mouse.fla
          //
          // Author:  Nick Pruehs
          // Date:    2011/05/04
          // 
          // (C) 2011 2nd Reality Studios. All Rights Reserved.
          // ============================================================================
          class HWGFxHUD_Mouse extends GFxMoviePlayer;
          
          /** The mouse cursor of the HUD. */
          var GFxObject MouseCursor;
          
          function bool Start(optional bool StartPaused = false)
          {
          	local bool bLoadErrors;
          
          	bLoadErrors = super.Start(StartPaused);
          
          	// initialize this movie clip without actually advancing the movie
                  Advance(0.f);
          
          	// ensure mouse cursor is always on top
          	MouseCursor = GetVariableObject("mouseCursor");
          	MouseCursor.SetBool("topmostLevel", true);
          
          	`log("ยงยงยง GUI: "$self$" has been started.");
          
          	return bLoadErrors; // (b && true = b)
          }
          
          
          DefaultProperties
          {
          	MovieInfo=SwfMovie'UI_HWHud.hwhud_mouse'
          
          	bDisplayWithHudOff=false    
                  TimingMode=TM_Real
          	bPauseGameWhileActive=false
          	bIgnoreMouseInput=false
          }
          Now you can load and start the movie whereever you want to in your HUD class, just like this:

          Code:
          GFxHUD_MouseMC = new class'HWGFxHUD_Mouse';
          GFxHUD_MouseMC.Start();
          Because we're still doing nothing else than drawing the mouse cursor in Scaleform, all previous interaction with the UDK engine should still work, like tracing actors etc. We just don't need to draw a cursor texture in UnrealScript anymore now.

          But there's still one problem left, as pointed out by _h2o_ in another thread I'm unfortunately unable to find ... All events fired by the mouse are processed in PlayerController::PlayerTick(float) before they're passed to the Scaleform GFx, which implies that you can't check whether the player has clicked a Scaleform button before the event has already been processed by the engine.

          In other words: If you're making an RTS-style game, you'll deselect all units every time you click a GUI button, for example.

          We developed a small hack that looks like this:

          Step 3: Ignoring mouse events if the Scaleform GFx GUI already has processed these events

          What we basically do is that we postpone processing all mouse input events to the following frame, in order to give the Scaleform GFx GUI a chance to tell us that the clicked has been processed there.

          First, every time a button is clicked, the PlayerController is notified by the event handler in UnrealScript:

          Code:
          function OnButtonPress(GFxClikWidget.EventData ev)
          {
              HWPlayerController(myHUD.PlayerOwner).NotifyScaleformButtonClicked();
              // ...
          }
          The PlayerController just remembers this:

          Code:
          /** Notifies this player controller that the last mouse click has been processed by the Scaleform GFx GUI and should not be processed by the engine. */
          function NotifyScaleformButtonClicked()
          {
          	bScaleformButtonClicked = true;
          }
          Now we just need to postpone all StartFire and StopFire events to the following frame. The following code has been taken from the PlayerController again:

          Code:
          event PlayerTick(float DeltaTime)
          {
          	// check for any released mouse buttons in the last frame
          	if (bLeftMouseJustReleased)
          	{
          		ReleasedLeftMouseButton();
          		bLeftMouseJustReleased = false;
          	}
          
          	if (bRightMouseJustReleased)
          	{
          		ReleasedRightMouseButton();
          		bRightMouseJustReleased = false;
          	}
          
          	// process player input for this frame
                  super.PlayerTick(DeltaTime);
          
                  // ...
          }
          
          exec function StopFire(optional byte FireModeNum )
          {
              // remember any mouse clicks and give the Scaleform GFx GUI the opportunity to check whether a GUI button has been clicked before processing the click
              if (FireModeNum == 0)
              {
                  bLeftMouseJustReleased = true;
              }
          
              if (FireModeNum == 1)
              {
                  bRightMouseJustReleased = true;
              }
          }
          
          /**
           * Called if the left mouse button has been released last frame, and processes
           * the click if it has not already been processed by the Scaleform GFx GUI.
           * Returns true is the click has been processed, and false otherwise.
           */
          function bool ReleasedLeftMouseButton()
          {
          	// don't process click further if Scaleform GFx GUI already did
          	if (bScaleformButtonClicked)
          	{
          		bScaleformButtonClicked = false;
          		return false;
          	}
          
          	// ...
          
          	return true;
          }
          
          /**
           * Called if the right mouse button has been released last frame, and processes
           * the click if it has not already been processed by the Scaleform GFx GUI.
           * Returns true if the click has been processed, and false otherwise.
           */
          function bool ReleasedRightMouseButton()
          {
          	// don't process click further if Scaleform GFx GUI already did
          	if (bScaleformButtonClicked)
          	{
          		bScaleformButtonClicked = false;
          		return false;
          	}
          
                  // ...
          
          	return true;
          }
          One of those nasty problems when making an RTS with the UDK - hope this helps

          Comment


            #6
            Thanks A LOT disRegard,that's an example how the help shoud be made
            But I have a question about that MovieInfo=SwfMovie'UI_HWHud.hwhud_mouse' - inside the .fla file is there only mouse cursor,or also some other GUI elements?

            Comment


              #7
              That Flash movie contains the mouse cursor, only. We follow the best practices described in http://www.scaleform.com/documents/g..._practices.pdf Section 4.1.

              Thus, our HUD class contains several instance variables for the different parts of the GUI, each of which derives from GFxMoviePlayer:

              Code:
              /** The window containing the ability buttons of the selected unit(s). */
              var HWGFxHUD_Abilities GFxHUD_AbilitiesMC;
              
              /** The status windows showing information on the selected unit(s). */
              var HWGFxHUD_StatusWindow GFxHUD_StatusWindowMC;
              
              /** The submenus allowing calling squad members and triggering tactical abilities. */
              var HWGFxHUD_Submenus GFxHUD_SubmenusMC;
              
              /** The command window providing access to all standard orders. */
              var HWGFxHUD_CommandWindow GFxHUD_CommandWindowMC;
              
              /** The window showing the current team scores and score limit. */
              var HWGFxHUD_VictoryPoints GFxHUD_VictoryPointsMC;
              
              /** The movie clip containing the mouse cursor to be drawn with highest priority. */
              var HWGFxHUD_Mouse GFxHUD_MouseMC;
              Before starting the match, these movies all are initialized and started:

              Code:
              // initialize Scaleform GFx HUD windows
              GFxHUD_AbilitiesMC = new class'HWGFxHUD_Abilities';
              GFxHUD_AbilitiesMC.myHUD = self;
              GFxHUD_AbilitiesMC.Start();
              GFxHUD_AbilitiesMC.SetAlignment(Align_CenterRight);
              GFxHUD_AbilitiesMC.Update();
              
              GFxHUD_StatusWindowMC = new class'HWGFxHUD_StatusWindow';
              GFxHUD_StatusWindowMC.myHUD = self;
              GFxHUD_StatusWindowMC.Start();
              GFxHUD_StatusWindowMC.SetAlignment(Align_BottomCenter);
              GFxHUD_StatusWindowMC.Update();
              
              GFxHUD_SubmenusMC = new class'HWGFxHUD_Submenus';
              GFxHUD_SubmenusMC.myHUD = self;
              GFxHUD_SubmenusMC.Start();
              GFxHUD_SubmenusMC.SetAlignment(Align_TopLeft);
              GFxHUD_SubmenusMC.Update();
              
              GFxHUD_CommandWindowMC = new class'HWGFxHUD_CommandWindow';
              GFxHUD_CommandWindowMC.myHUD = self;
              GFxHUD_CommandWindowMC.Start();
              GFxHUD_CommandWindowMC.SetAlignment(Align_BottomRight);
              GFxHUD_CommandWindowMC.Update();
              
              GFxHUD_VictoryPointsMC = new class'HWGFxHUD_VictoryPoints';
              GFxHUD_VictoryPointsMC.myHUD = self;
              GFxHUD_VictoryPointsMC.Start();
              GFxHUD_VictoryPointsMC.SetAlignment(Align_TopCenter);
              GFxHUD_VictoryPointsMC.Update();
              
              GFxHUD_MouseMC = new class'HWGFxHUD_Mouse';
              GFxHUD_MouseMC.Start();
              As you can see, the mouse clip containing the mouse cursor is one of them.

              The definitions of myHUD and Update are part of our own base class HWGFxHUDView which derives from GFxMoviePlayer and ensures that all parts of the GUI show similar behavior concerning scaling and timing, for example.

              Comment


                #8
                When I wrote the development kit, I never had ScaleForm in mind. So of course it didn't work out of the box.

                I've now updated the development kit gem to include the option to have ScaleForm drive the mouse cursor if the developer desires.

                Comment


                  #9
                  What exactly you mean Solid Snake??In the description of the tutorial there is a sentence "Last tested against UDK Apr, 2011",so I assumed it is accurate.

                  Comment


                    #10
                    When I first wrote the document, I did not write it with ScaleForm in mind, hence why when you first read it, it did not have ScaleForm integration. This is because ScaleForm is not the only method to create a GUI in Unreal Engine 3.

                    I have recently updated the document so that it shows how you would use ScaleForm with it now.

                    Comment


                      #11
                      Thanks Solid Snake for your solution,
                      but I'm having some trouble with your classes. I like to build a hud with a mouse cursor in front of it via scaleform but the cursor doesn't show up.
                      I'm sure that I've set the right Default Properties in the MouseInterfaceGFx.uc (to the imported cursor) but the only way to show it is open it via the open Gfx node in kismet
                      which is not right, I guess?

                      Any Help would be appreciated.

                      Thanks in advance.

                      Comment


                        #12
                        Does it work with the examples provided?

                        Comment


                          #13
                          Yes, it does I didn't realize, that you have updated the download examples also.
                          Thanks for your Help!

                          Comment


                            #14
                            Hey all!

                            So after using that tutorial I too made a mouse using the Scale Form option (The Unreal script option was giving me a lot of problems) and in the future my HUD will be scale form so I thought to do it in scale form now but after I implemented the mouse my pawn and Camera set-ups all disappeared! I was not able to do anything except move the mouse and move in straight directions!


                            Does anyone know what the problem might be?


                            Edit : I did check the log on my camera switching functions and it is being called but nothing is happening in the game, there is only the map and the mouse. What would I need to do to call my pawn and camera with the tutorial mentioned by the OP

                            Comment


                              #15
                              Did you make sure to use your own PlayerController and modify according to the development kit gems, or are you using the PlayerController in the gem?

                              Comment

                              Working...
                              X