Main Menu: Difference between revisions
No edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 80: | Line 80: | ||
<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. | <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. | ||
=== Control flow reference === | === Control flow reference === | ||
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.
| 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
PlayerPrefsand applied to the audio listener before extended playback. - Import: External
.pcfiles 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)
- The player selects a save entry, or the application loads a preset or example file.
- The active
DataLoaderinstance is registered for the subsequent scene. - The target scene index is derived from saved
GameData.roomrelative 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")
|