(Created page with "{{DISPLAYTITLE:Main Menu}} {{about|the title screen and front-end of ''PC Simulator''|the in-game pause overlay|Pause menu}} The '''main menu''' is the first interactive screen in ''PC Simulator'' after the '''Menu''' scene loads. It is driven by the {{mono|MainMenu}} behaviour, which initializes localization, restores certain settings, presents navigation via {{mono|MenuManager}}, and starts asynchronous scene loads with a dedicated '''Loading''' page....")
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Main Menu}}
The '''main menu''' is the primary user interface presented when '''[[PC Simulator]]''' starts. It is implemented in the Menu scene and provides access to saved games, the [[Tutorial]], configuration options, and application exit. Save data uses the <code>.pc</code> format documented at [[Save]]; external editing is described at [[Save Editor]]. Discoverable interactions that load preset saves are summarized at [[Secrets]]; the hidden-room achievement context appears at [[Achievements:The Hidden Room]].
{{about|the title screen and front-end of ''PC Simulator''|the in-game pause overlay|Pause menu}}


The '''main menu''' is the first interactive screen in ''[[PC Simulator]]'' after the '''Menu''' scene loads. It is driven by the {{mono|MainMenu}} behaviour, which initializes [[localization]], restores certain settings, presents navigation via {{mono|[[MenuManager]]}}, and starts [[asynchronous]] scene loads with a dedicated '''Loading''' page.
{| style="float:right; width:280px; margin:0 0 1em 1em; border-collapse:collapse; border:1px solid #c8ccd1; background:#f8f9fa; font-size:92%;"
|+ style="background:#eaecf0; border:1px solid #c8ccd1; padding:6px; font-weight:bold;" | Summary
|-
| style="border:1px solid #c8ccd1; padding:6px;" | '''Function'''
| style="border:1px solid #c8ccd1; padding:6px;" | Front-end hub for starting play, managing saves, and adjusting session settings
|-
| style="border:1px solid #c8ccd1; padding:6px;" | '''Save format'''
| style="border:1px solid #c8ccd1; padding:6px;" | <code>.pc</code> files; see [[Save]]
|-
| style="border:1px solid #c8ccd1; padding:6px;" | '''Related economy'''
| style="border:1px solid #c8ccd1; padding:6px;" | [[Bitcoin]] and in-game mining ([[EZ Mining]]) apply after gameplay begins
|-
| style="border:1px solid #c8ccd1; padding:6px;" | '''Presentation'''
| style="border:1px solid #c8ccd1; padding:6px;" | The title text alternates to simulate a blinking cursor
|}


== Overview ==
<div style="clear:both;"></div>


The main menu acts as the hub for:
== Purpose and functions ==


* Starting or resuming a game from '''save files''' ({{mono|.pc}}) in the user save folder
The main menu exposes the following capabilities:
* Launching the '''[[Tutorial]]''' scene (and recording that the current tutorial version has been offered)
* Loading '''example''' presets from '''StreamingAssets/Examples''' (e.g. named saves such as {{mono|Classic.pc}}, versioned examples, or {{mono|Hidden Room.pc}} when triggered from in-game secrets)
* Opening sub-pages for options, language, credits, file management, etc. (each implemented as a child page under {{mono|MenuManager}})
* '''Exiting''' the application on supported platforms


The on-screen title alternates between {{mono|PC Simulator}} and {{mono|PC Simulator_}} with a blinking underscore, with {{mono|PC}} highlighted in orange (Rich Text on Unity UI).
* '''Game load:''' Saved games are listed, typically ordered by most recent file modification time. Saves flagged as hardcore may display a dedicated indicator in the user interface.
* '''Tutorial access:''' If the stored tutorial revision is older than the value configured in the build, a prompt object is shown. Accepting the tutorial updates the stored revision and loads the Tutorial scene.
* '''Settings:''' Frame rate and resolution preferences are restored when the menu initializes so that the initial view matches prior configuration.
* '''Audio:''' Master volume is read from <code>PlayerPrefs</code> and applied to the audio listener before extended playback.
* '''Import:''' External <code>.pc</code> files may be selected, validated, and copied into the user save directory. Invalid or incompatible files produce an error message. This workflow supports distribution and [[Modding]].
* '''Exit:''' The application requests termination via <code>Application.Quit</code>. Behaviour depends on platform; the Unity Editor may show no visible shutdown.


== Localization ==
== Load sequence (overview) ==


On {{mono|Awake}}, the menu:
# The player selects a save entry, or the application loads a preset or example file.
# The active <code>DataLoader</code> instance is registered for the subsequent scene.
# The target scene index is derived from saved <code>GameData.room</code> relative to a configured base build index.


# Calls {{mono|Localization.CreateContent()}}
Certain [[Secrets]] and achievement-related paths load example content from streaming assets rather than the user save folder. The programmatic path parallels normal save loading once the file contents are obtained. See [[Achievements:The Hidden Room]] for the documented hidden-room case.
# Sets the active language from {{mono|PlayerPrefs}} key {{mono|"Language"}}, or falls back to a code derived from {{mono|Application.systemLanguage}} (e.g. {{mono|EN}}, {{mono|DE}}, {{mono|ZH-CN}}, {{mono|JA}}, and many others)
# Subscribes to {{mono|Localization.LanguageChanged}} to persist the chosen language back to {{mono|PlayerPrefs}}


== Settings restored at menu start ==
== In-depth ==


In {{mono|Start}}, the menu restores:
The following subsection describes implementation-level behaviour consistent with the decompiled project structure. Asset extraction is discussed at [[Decompile]]; extension of behaviour at [[Modding]].


* '''FPS''' settings via {{mono|FpsSetting.RestoreSetting()}}
=== Core components ===
* '''Resolution''' via {{mono|ResolutionSetting.RestoreSetting()}}
* '''Master volume''' on the audio listener from {{mono|PlayerPrefs}} (key {{mono|"Volume"}}, default {{mono|1f}})


== Tutorial prompt ==
{| style="border-collapse:collapse; width:100%; border:1px solid #c8ccd1;"
|- style="background:#eaecf0;"
! style="border:1px solid #c8ccd1; padding:8px; text-align:left; width:22%;" | Type
! style="border:1px solid #c8ccd1; padding:8px; text-align:left;" | Description
|-
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | <code>MainMenu</code>
| style="border:1px solid #c8ccd1; padding:8px;" | MonoBehaviour singleton exposed as <code>MainMenu.Instance</code>. Initializes localization, restores display settings, controls tutorial gating, drives the title animation, performs asynchronous scene loads, loads example files, and invokes quit.
|-
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | <code>MenuManager</code>
| style="border:1px solid #c8ccd1; padding:8px;" | Maintains a stack of active menu <code>GameObject</code> roots. <code>ShowMenu(string)</code> activates the child whose object name matches the argument (for example <code>Loading</code>). <code>Back</code> removes the current page when the stack depth exceeds one. <code>HideMenu</code> toggles visibility of the top entry without altering stack order. Optional audio feedback may be enabled.
|-
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | <code>FileMenu</code>
| style="border:1px solid #c8ccd1; padding:8px;" | Enumerates save files, constructs list entries, supports metadata editing through <code>FileInformation</code>, deletion, and import via native file selection.
|}


If {{mono|PlayerPrefs.GetInt("TutorialVersion", -1)}} is strictly less than a serialized {{mono|tutorialVersion}} on the menu component, the '''guide to tutorial''' object is shown; otherwise it is hidden. Entering the tutorial via {{mono|Tutorial()}} sets {{mono|TutorialVersion}} to the current version and loads the '''Tutorial''' scene by name.
=== Localization ===


== Navigation stack ==
During <code>Awake</code>, <code>MainMenu</code> invokes <code>Localization.CreateContent()</code>, sets the active language from stored preferences or from <code>Application.systemLanguage</code>, and registers a handler so language changes persist. Further string tables and language codes may be documented at [[Localization]].


The {{mono|MenuManager}} component maintains a '''stack''' of active menu {{mono|GameObject}} pages:
=== Tutorial revision flag ===


* {{mono|ShowMenu(string pageName)}} finds a child menu whose '''name''' matches {{mono|pageName}}, hides the current top if different, and pushes the new page
The integer <code>TutorialVersion</code> in <code>PlayerPrefs</code> is compared to the serialized <code>tutorialVersion</code> field. When the stored value is lower, the guide object is enabled. The <code>Tutorial()</code> method writes the current revision and loads the scene named <code>Tutorial</code>.
* {{mono|Back()}} pops the stack (if more than one entry) and reactivates the previous page
* {{mono|HideMenu(bool hide)}} toggles visibility of the top page without changing the stack (used when gameplay hides UI)
* Optional '''click''' sounds can play on navigation when enabled


Loading a scene always calls {{mono|ShowMenu("Loading")}} first so the player sees the loading overlay for the duration of the async operation.
=== Asynchronous loading ===


== Loading screen behaviour ==
Scene transitions display a <code>Loading</code> menu page, then execute an asynchronous load. Reported progress is scaled so that the engine’s <code>0.9</code> completion point maps to a 100 percent display value. After reaching that threshold, the interface shows 100 percent, delays for a fixed interval, then permits scene activation. A dedicated article may appear at [[Loading screen]].


Scene loads use {{mono|SceneManager.LoadSceneAsync}} with {{mono|allowSceneActivation}} held at {{mono|false}} until progress reaches {{mono|0.9f}}. The displayed percentage uses:
=== Save and example loading ===


: <code>Mathf.Clamp01(operation.progress / 0.9f) * 100f</code>
<code>LoadFile(DataLoader loader)</code> assigns <code>SaveManager.Loader</code> and loads the build index <code>startRoomSceneIndex + GameData.room</code>. The inspector-configured <code>startRoomSceneIndex</code> aligns logical room identifiers with the editor build order.


When progress is at least {{mono|0.9f}}, the text shows '''100%''', waits '''0.5''' seconds, then allows activation. The label uses the localized string for {{mono|"Loading..."}} plus a bracketed percentage on a new line.
<code>LoadExample(string name)</code> reads <code>StreamingAssets/Examples/{name}.pc</code>. On Android and WebGL the implementation uses <code>UnityWebRequest</code>; on other platforms it uses direct file read APIs. The payload is passed to <code>DataLoader.LoadFromString</code>, followed by <code>LoadFile</code>. Bundled asset names may be listed at [[StreamingAssets]].


== Save files and examples ==
=== Import implementation ===


=== User saves ===
<code>FileMenu.Import</code> opens a native picker restricted to <code>.pc</code> extensions, verifies read access, attempts <code>DataLoader.LoadFromPath</code>, copies the file into the save directory using <code>SaveUtility.GetNewPath</code>, destroys existing list rows, and rebuilds the list from disk. Parse failures surface a localized error referencing minimum supported save versions.


The '''File menu''' ({{mono|FileMenu}}) scans the save directory for files matching the save extension, sorts them by '''last write time''' (newest first), and instantiates a slot per valid file. Each slot shows the save’s {{mono|roomName}} and a '''Hardcore''' indicator when {{mono|GameData.hardcore}} is true. Clicking the name button calls {{mono|MainMenu.Instance.LoadFile(loader)}}, which assigns {{mono|SaveManager.Loader}} and loads the scene index {{mono|startRoomSceneIndex + GameData.room}}.
=== Control flow reference ===


=== Example presets ===
{| style="border-collapse:collapse; width:100%; border:1px solid #c8ccd1;"
 
|- style="background:#eaecf0;"
{{mono|LoadExample(string name)}} reads {{mono|StreamingAssets/Examples/<name>.pc}}. On '''Android''' and '''WebGL''', the file is fetched with {{mono|UnityWebRequest}}; on other platforms, {{mono|File.ReadAllText}} is used. The string is passed through {{mono|DataLoader.LoadFromString}} and then the same {{mono|LoadFile}} path as a user save.
! style="border:1px solid #c8ccd1; padding:8px; text-align:left; width:28%;" | Event
 
! style="border:1px solid #c8ccd1; padding:8px; text-align:left;" | Processing
== Starting gameplay scenes ==
|-
 
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | Save name activated
* '''Indexed rooms:''' {{mono|LoadScene(int sceneBuildIndex)}} loads build index {{mono|startRoomSceneIndex + sceneBuildIndex}}, where {{mono|sceneBuildIndex}} comes from the save’s {{mono|room}} field.
| style="border:1px solid #c8ccd1; padding:8px;" | <code>MainMenu.LoadFile</code>; <code>SaveManager.Loader</code> assignment; asynchronous load of <code>startRoomSceneIndex + room</code>
* '''Named scenes:''' {{mono|LoadScene(string sceneName)}} loads by name (used for the tutorial).
 
== Exit ==
 
{{mono|Exit()}} calls {{mono|Application.Quit()}}. On some platforms (e.g. editor or certain mobile builds), this may have no visible effect.
 
== Implementation notes ==
 
{| class="wikitable"
! Unity component || Role
|-
|-
| {{mono|MainMenu}} || Singleton {{mono|Instance}}; localization; tutorial gating; scene and example loading; title blink coroutine ({{mono|InvokeRepeating}} every 0.5 s)
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | Example or secret preset
| style="border:1px solid #c8ccd1; padding:8px;" | <code>LoadExample</code> from streaming assets; then <code>LoadFile</code>
|-
|-
| {{mono|MenuManager}} || Stack of menu pages; show/back/hide; optional UI click sound
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | Scene transition from menu
| style="border:1px solid #c8ccd1; padding:8px;" | <code>ShowMenu("Loading")</code>; coroutine until activation allowed
|-
|-
| {{mono|FileMenu}} || Lists saves, import, file info sub-page
| style="border:1px solid #c8ccd1; padding:8px; vertical-align:top;" | Tutorial accepted
| style="border:1px solid #c8ccd1; padding:8px;" | <code>TutorialVersion</code> updated; <code>LoadScene("Tutorial")</code>
|}
|}


== See also ==
== See also ==


* [[Tutorial]]
* [[PC Simulator]]
* [[Save file format]] <!-- optional redlink if you document GameData elsewhere -->
* [[Save]] · [[Save Editor]]
* [[Pause menu]]
* [[Secrets]] · [[Achievements:The Hidden Room]]
* [[Achievements]] <!-- e.g. hidden room loads example save -->
* [[Bitcoin]] · [[EZ Mining]]
 
* [[Modding]] · [[Decompile]]
[[Category:PC Simulator]]
* [[Main Page]]
[[Category:User interface]]

Latest revision as of 18:20, 22 March 2026

The main menu is the primary user interface presented when PC Simulator starts. It is implemented in the Menu scene and provides access to saved games, the Tutorial, configuration options, and application exit. Save data uses the .pc format documented at Save; external editing is described at Save Editor. Discoverable interactions that load preset saves are summarized at Secrets; the hidden-room achievement context appears at Achievements:The Hidden Room.

Summary
Function Front-end hub for starting play, managing saves, and adjusting session settings
Save format .pc files; see Save
Related economy Bitcoin and in-game mining (EZ Mining) apply after gameplay begins
Presentation The title text alternates to simulate a blinking cursor

Purpose and functions

The main menu exposes the following capabilities:

  • Game load: Saved games are listed, typically ordered by most recent file modification time. Saves flagged as hardcore may display a dedicated indicator in the user interface.
  • Tutorial access: If the stored tutorial revision is older than the value configured in the build, a prompt object is shown. Accepting the tutorial updates the stored revision and loads the Tutorial scene.
  • Settings: Frame rate and resolution preferences are restored when the menu initializes so that the initial view matches prior configuration.
  • Audio: Master volume is read from PlayerPrefs and applied to the audio listener before extended playback.
  • Import: External .pc files may be selected, validated, and copied into the user save directory. Invalid or incompatible files produce an error message. This workflow supports distribution and Modding.
  • Exit: The application requests termination via Application.Quit. Behaviour depends on platform; the Unity Editor may show no visible shutdown.

Load sequence (overview)

  1. The player selects a save entry, or the application loads a preset or example file.
  2. The active DataLoader instance is registered for the subsequent scene.
  3. The target scene index is derived from saved GameData.room relative to a configured base build index.

Certain Secrets and achievement-related paths load example content from streaming assets rather than the user save folder. The programmatic path parallels normal save loading once the file contents are obtained. See Achievements:The Hidden Room for the documented hidden-room case.

In-depth

The following subsection describes implementation-level behaviour consistent with the decompiled project structure. Asset extraction is discussed at Decompile; extension of behaviour at Modding.

Core components

Type Description
MainMenu MonoBehaviour singleton exposed as MainMenu.Instance. Initializes localization, restores display settings, controls tutorial gating, drives the title animation, performs asynchronous scene loads, loads example files, and invokes quit.
MenuManager Maintains a stack of active menu GameObject roots. ShowMenu(string) activates the child whose object name matches the argument (for example Loading). Back removes the current page when the stack depth exceeds one. HideMenu toggles visibility of the top entry without altering stack order. Optional audio feedback may be enabled.
FileMenu Enumerates save files, constructs list entries, supports metadata editing through FileInformation, deletion, and import via native file selection.

Localization

During Awake, MainMenu invokes Localization.CreateContent(), sets the active language from stored preferences or from Application.systemLanguage, and registers a handler so language changes persist. Further string tables and language codes may be documented at Localization.

Tutorial revision flag

The integer TutorialVersion in PlayerPrefs is compared to the serialized tutorialVersion field. When the stored value is lower, the guide object is enabled. The Tutorial() method writes the current revision and loads the scene named Tutorial.

Asynchronous loading

Scene transitions display a Loading menu page, then execute an asynchronous load. Reported progress is scaled so that the engine’s 0.9 completion point maps to a 100 percent display value. After reaching that threshold, the interface shows 100 percent, delays for a fixed interval, then permits scene activation. A dedicated article may appear at Loading screen.

Save and example loading

LoadFile(DataLoader loader) assigns SaveManager.Loader and loads the build index startRoomSceneIndex + GameData.room. The inspector-configured startRoomSceneIndex aligns logical room identifiers with the editor build order.

LoadExample(string name) reads StreamingAssets/Examples/{name}.pc. On Android and WebGL the implementation uses UnityWebRequest; on other platforms it uses direct file read APIs. The payload is passed to DataLoader.LoadFromString, followed by LoadFile. Bundled asset names may be listed at StreamingAssets.

Import implementation

FileMenu.Import opens a native picker restricted to .pc extensions, verifies read access, attempts DataLoader.LoadFromPath, copies the file into the save directory using SaveUtility.GetNewPath, destroys existing list rows, and rebuilds the list from disk. Parse failures surface a localized error referencing minimum supported save versions.

Control flow reference

Event Processing
Save name activated MainMenu.LoadFile; SaveManager.Loader assignment; asynchronous load of startRoomSceneIndex + room
Example or secret preset LoadExample from streaming assets; then LoadFile
Scene transition from menu ShowMenu("Loading"); coroutine until activation allowed
Tutorial accepted TutorialVersion updated; LoadScene("Tutorial")

See also