Skip to content

Widgets

zminton edited this page Sep 10, 2018 · 4 revisions

Widgets are a feature of the Unreal Engine 4 for user interfacing; they allow the creation and display of menu screens and other similar functions. The Trolley Mod uses Widgets both as a status display and for specifying how the simulation will be run. There are two Widget Blueprint classes: HitResult and StartMenu.

HitResult

Summary: when a victim Actor is hit in a scenario, HitREsult displays this result on-screen to the player, i.e. "You hit a pedestrian."

Global variables

  1. Text (static text Widget): this is a simple line of text that changes to reflect the result of the collision.

Functions

  1. ChangeDisplay: accepts an Actor reference to change the value of Text depending on what type of Actor was hit. The function will make the display visible for only a few seconds, and then make it invisible until the next collision in order to keep the player immersed.
    • Variables (none)
    • Inputs
      • Victim (Actor object reference): the Actor that was hit during the collision.
    • Outputs (none)

StartMenu

Summary: this provides a basic user interface at the start of the simulation. It allows a user to run the simulation in two modes: Single and Continuous. Continuous mode will run the simulation from start to finish, touching on all scenarios generated in the map. Otherwise, if Single mode is specified the simulation will only run the scenario that has the test number specified by the user. In addition, it allows the user to specify the name of the output file and whether or not to overwrite it.

Global Variables

  1. CheckBox (checkbox Widget)_: if checked, it indicates a user wants to overwrite the output save file.
  2. ContinueButton (button Widget): if clicked, the simulation will be run in Continuous mode.
  3. FileBox (textbox Widget): the text in FileBox is the name of the output file; by default, it is “test.” A “.txt” extension is appended to the file name automatically.
  4. IsSingleTest (bool): signals the simulation to terminate after running the current simulation if true.
  5. Overwrite (bool): stores the status of CheckBox for reference by other functions; in other words, it stores whether the user wants to overwrite the output file. If the value is true, then the file is overwritten.
  6. SaveFile (string): stores the name of the output file.
  7. SingleButton (button Widget): if clicked, the simulatoin will be run in Single mode.
  8. TestNumBox (textbox Widget): accepts an integer from the user corresponding to a scenario’s test number for use in Single mode. If it is left blank, then the first scenario is run by default.

Functions

  1. SingleTest: use the integer value from TestNumBox to look for the Target Actor with the corresponding test number property. If it is found, it moves the player Pawn there, runs the simulation at that location, and then returns true to indicate for the simulation to terminate.
    • Variables
      • Bool (bool): a temporary value that stores true if the simulation successfully found a scenario with the test number equal to the value in TestNumBox.
    • Inputs (none)
    • Outputs (none)