ScreenMaster.cs - MitchOSully/Visualising-the-DFN-Dataset GitHub Wiki

Summary

Looks after everything to do with the GUI system on the screen, which mostly entails displaying or hiding GUI elements when the game is paused or a button is pressed.

In the Unity project, this script is added as a component to the screen canvas.

TO DO: include a labelled diagram of the screen with all GUI elements.

List of Functions

Public Global Variables
Private Global Variables

void start()
void update()
void pauseGame()
void resumeGame()
void hideControls()
void showControls()
void controlTutorialPanel()
void controlSettingsPanel()
void displayInfoPanel(string title, string info, string citation)
void closeInfoPanel()
void changeSpeed(float inSliderValue)
void setUsingTimeSlider(bool inUsingTimeSlider)
void changeDateLive(string newDate)
void changeDateEnd(string newDate)
void displayErrorMessage(string message)
void planetScaleAUTO(bool isOn)
void planetScaleREAL(bool isOn)
void planetScaleCUSTOM(float inScale)
void sunScaleAUTO(bool isOn)
void sunScaleREAL(bool isOn)
void sunScaleCUSTOM(float inScale)
void meteorScaleAUTO(bool isOn)
void meteorScaleCUSTOM(float inScale)

Public Global Variables

BodyPlotter plotterScript

Reference to the BodyPlotter.cs script for checking daysElapsed, paused and other variables.

DateHelper helper

Reference to the DateHelper.cs script for displaying a JD (Julian Day) in the form dd/mm/yyyy.

CameraController cameraScript

Reference to the CameraController.cs script for changing the camera pivots.

bool clickingActive

A Boolean that tells the CameraController script if the user's cursor is over a GUI element. If it is, then we must deactivate all dragging and scrolling capabilities that change the location of the camera.


The following variables are all references to GUI elements that we must activate/deactivate at certain times.

GameObject topLeftPanel

This panel only contains the pivot menu.

GameObject pivotMenu

GameObject topRightPanel

This panel contains the date input-box, the speed slider and the small panel that displays the error messages

GameObject dateInput

GameObject speedSlider

GameObject errorMessagePrefab

GameObject topCenterPanel

This panel contains the pause and play buttons as well as the time slider.

GameObject pauseButton

GameObject playButton

GameObject timeSlider

GameObject bottomRightPanel

This panel contains the hide and show controls buttons, the tutorial button and panel, the settings button and panel and everything inside the settings panel.

GameObject hideButton

GameObject showButton

GameObject tutorialButton

GameObject tutorialPanel

GameObject settingsButton

GameObject settingsPanel

This panel is part of the bottom right panel. It contains the 'meteor lines' panel, 'meteor lines gone' panel, 'auto planet scale' toggle, 'real planet scale' toggle, planet scale slider, 'auto sun scale' toggle, 'real sun scale' toggle, sun scale slider, 'auto meteor scale' toggle and the meteor scale slider.

GameObject meteorLinesPanel

GameObject meteorLinesGonePanel

GameObject planetScaleAutoToggle

GameObject planetScaleRealToggle

GameObject planetScaleSlider

GameObject sunScaleAutoToggle

GameObject sunScaleRealToggle

GameObject sunScaleSlider

GameObject meteorScaleAutoToggle

GameObject meteorScaleSlider

GameObject infoPanel

This panel is displayed when the user right-clicks on a planet or meteoroid. It shows information about that body. It contains the title, text (all the information), citation and the scrollbar.

GameObject infoPanelTitle

GameObject infoPanelText

GameObject infoPanelCitation

GameObject infoPanelScrollbar

Private Global Variables

bool usingTimeSlider = false

Tells us if the time-slider (a GUI element that changes time) is being used.

void start()

If showMeteorLines in BodyPlotter is false, then it deactivates the 'meteor lines' panel in the settings window and replaces it with the 'meteor lines gone' panel.

Params

None

Returns

None

Calls

None

Called By

void update()

Updates the current time displayed in the date input-box (top-right corner) and the time slider (spans top of screen).

If the game is in play mode, updates time in both places. If game is in pause mode but we're using the time slider, only updates time in date input-box. If game is paused and we're not using the slider, nothing is updated.

Params

None

Returns

None

Calls

Called By

void pauseGame()

Deactivates pause button and activates play button. Also makes the date input-box and time-slider interactable.

Params

None

Returns

None

Calls

None

Called By

  • The pause button at top-centre of screen.

void resumeGame()

Deactivates play button and activates pause button. Also makes the date input-box and time-slider uninteractable.

Params

None

Returns

None

Calls

None

Called By

  • The play button at top-centre of screen.

void hideControls()

Deactivates 'hide controls' button and activates 'show controls' button. Also deactivates the following panels:

  • Top-left panel.
  • Top-right panel.
  • Top-centre panel.
  • Tutorial panel.
  • Settings panel.

Params

None

Returns

None

Calls

None

Called By

The 'hide controls' button in lower right corner.

void showControls()

Deactivates 'show controls' button and activates 'hide controls' button. Also activates the following panels:

  • Top-left panel.
  • Top-right panel.
  • Top-centre panel.

Params

None

Returns

None

Calls

None

Called By

  • The 'show controls' button in lower-right corner.

void controlTutorialPanel()

If the tutorial panel is not active, it activates it. If it is, it deactivates it. Also deactivates the settings panel in both cases.

Params

None

Returns

None

Calls

None

Called By

  • The tutorial '?' button in lower-right corner.

void controlSettingsPanel()

If settings panel is not active, it activates it. If it is, it deactivates it. Also deactivates the tutorial panel in both cases.

Params

None

Returns

None

Calls

None

Called By

  • The settings button (cog symbol) in lower-right corner.

void displayInfoPanel(string title, string info, string citation)

Displays a panel that shows information about a planet or meteoroid when the user right-clicks on it.

TO DO: picture of info panels of planet and meteoroid.

Params

Name Type Description
title string The name of the planet or meteoroid. Shown in large font at the top of the info panel.
info string All the information about the body in question. This text fills up the whole panel.
citation string The source of the information. NASA if it's a planet. DFN if it's a meteoroid. Displayed in small font at the bottom of the panel.

Returns

None

Calls

None

Called By

void closeInfoPanel()

Resets the scrollbar and deactivates the info panel. Also sets clickingActive back to true, as well as scrollingActive in CameraController.

Params

None

Returns

None

Calls

None

Called By

  • The 'X' button in top-right corner of info panel.

void changeSpeed(float inSliderValue)

Updates the daysPerFrame value in BodyPlotter and the text on the speed slider.

Params

Name Type Description
inSliderValue float The new speed selected by the slider.

Returns

None

Calls

None

Called By

None

void setUsingTimeSlider(bool inUsingTimeSlider)

Sets the value of the global variable usingTimeSlider to whatever is imported.

Params

Name Type Description
inUsingTimeSlider bool The new value, either true or false.

Returns

None

Calls

None

Called By

void changeDateLive(string newDate)

If the input is a valid date in dd/mm/yyyy form, then it changes the value of the time slider, which in turn alters the current date.

Params

Name Type Description
newDate string The input of the user in the date input-box. Should be in the form "dd/mm/yyyy".

Returns

None

Calls

Called By

  • The date input-box, whenever the user edits the date (before they press 'enter').

void changeDateEnd(string newDate)

If the input is invalid, displays the 'error message' panel. If it's valid we do nothing since it was already done in changeDateLive.

Params

Name Type Description
newDate string The input from the date input-box. Should be in the form "dd/mm/yyyy".

Returns

None

Calls

Called By

  • The date input-box, when the user presses 'enter' while in the date input-box.

void displayErrorMessage(string message)

Displays the 'error message' panel when the wrong input is given to the date input-box.

Params

Name Type Description
message string The message to display in red writing in the middle of the panel.

Returns

None

Calls

Called By

void planetScaleAUTO(bool isOn)

GUI Method

Changes the planet scale slider value to 1 (the actual size-changing is done in BodyPlotter).

Called By

  • The 'Planet Scale Auto' toggle in 'Settings' panel.

void planetScaleREAL(bool isOn)

GUI Method

Changes the planet scale slider value to 0 because the real planet scales are very close to 0 (the actual size-changing is done in BodyPlotter).

Called By

  • The 'Planet Scale Real' toggle in 'Settings' panel.

void planetScaleCUSTOM(float inScale)

GUI Method

Turns the auto and real toggles off and changes the text on the slider to reflect the new scale.

Called By

  • The slider bar under 'Planet Scale' in 'Settings' panel.

void sunScaleAUTO(bool isOn)

GUI Method

Changes the sun scale slider value to 1 (the actual size-changing is done in BodyPlotter).

Called By

  • The 'Sun Scale Auto' toggle in 'Settings' panel.

void sunScaleREAL(bool isOn)

GUI Method

Changes the sun scale slider value to 0 since the actual value is very close to 0 (the actual size-changing is done in BodyPlotter).

Called By

  • The 'Sun Scale Real' toggle in 'Settings' panel.

void sunScaleCUSTOM(float inScale)

GUI Method

Turns the auto and real toggles off and changes the text on the slider to reflect the new scale.

Called By

  • The slider bar under 'Sun Scale' in 'Settings' panel.

void meteorScaleAUTO(bool isOn)

GUI Method

Changes the meteoroid scale slider value to 0.3 (the actual size-changing is done in BodyPlotter).

Called By

  • The 'Meteoroid Scale Auto' toggle in 'Settings' panel.

void meteorScaleCUSTOM(float inScale)

GUI Method

Deactivates the auto toggle and changes the text on the slider to reflect the new scale.

Called By

  • The slider bar under 'Meteoroid Scale' in 'Settings' panel.