menu
This commit is contained in:
1 parent
5135c50172
commit
268608a459
46 files changed
+5298
-74
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class DebugLogPanel : MonoBehaviour
|
||||
{
|
||||
uint qsize = 15; // number of messages to keep
|
||||
Queue myLogQueue = new Queue();
|
||||
|
||||
void Start() {
|
||||
Debug.Log("SpaceRace!");
|
||||
Debug.Log("WSAD - Strafe");
|
||||
Debug.Log("Mouse 1 - Thrust");
|
||||
Debug.Log("Mouse 2 - Decelerate");
|
||||
Debug.Log("Space - Respawn");
|
||||
Debug.Log("F10 - Exit");
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
Application.logMessageReceived += HandleLog;
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
Application.logMessageReceived -= HandleLog;
|
||||
}
|
||||
|
||||
void HandleLog(string logString, string stackTrace, LogType type) {
|
||||
// myLogQueue.Enqueue("[" + type + "] : " + logString);
|
||||
myLogQueue.Enqueue(logString);
|
||||
if (type == LogType.Exception)
|
||||
myLogQueue.Enqueue(stackTrace);
|
||||
while (myLogQueue.Count > qsize)
|
||||
myLogQueue.Dequeue();
|
||||
}
|
||||
|
||||
void OnGUI() {
|
||||
GUILayout.BeginArea(new Rect(0, 0, 400, Screen.height));
|
||||
GUILayout.Label("\n" + string.Join("\n", myLogQueue.ToArray()));
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13ee45edf9a5f1c6789b5ce48c7ee4a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,5 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<Style src="ShipUi.uss" />
|
||||
<ui:VisualElement name="lap-time-entry">
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0634235ba7ac8c449247dcb52927cd6
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,61 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class MenuControls : MonoBehaviour, SpaceRaceInput.IMenuActions {
|
||||
[SerializeField]
|
||||
UIDocument menuDoc;
|
||||
|
||||
[SerializeField]
|
||||
UIDocument timingDoc;
|
||||
|
||||
[SerializeField]
|
||||
ShipControls shipControls;
|
||||
|
||||
SpaceRaceInput input;
|
||||
bool visible = false;
|
||||
|
||||
void Start() {
|
||||
if (input == null) {
|
||||
input = new SpaceRaceInput();
|
||||
input.menu.SetCallbacks(this);
|
||||
}
|
||||
input.menu.Enable();
|
||||
Debug.Log($"Menu {visible}");
|
||||
Hide();
|
||||
}
|
||||
|
||||
void Show() {
|
||||
visible = true;
|
||||
UnityEngine.Cursor.lockState = CursorLockMode.None;
|
||||
menuDoc.enabled = true;
|
||||
|
||||
// take control off the ship
|
||||
timingDoc.enabled = false;
|
||||
shipControls.enabled = false;
|
||||
|
||||
}
|
||||
|
||||
void Hide() {
|
||||
visible = false;
|
||||
UnityEngine.Cursor.lockState = CursorLockMode.Locked;
|
||||
menuDoc.enabled = false;
|
||||
|
||||
// resume control of the ship
|
||||
timingDoc.enabled = true;
|
||||
shipControls.enabled = true;
|
||||
}
|
||||
|
||||
public void OnToggleMenu(InputAction.CallbackContext ctx) {
|
||||
visible = !visible;
|
||||
Debug.Log($"Menu {visible}");
|
||||
|
||||
if (visible) {
|
||||
Show();
|
||||
return;
|
||||
}
|
||||
|
||||
Hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7da082ca2a8e6ee9a5b1151245f535f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,284 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.6.1
|
||||
// from Assets/Src/UI/MenuInput.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
public partial class @MenuInput: IInputActionCollection2, IDisposable
|
||||
{
|
||||
public InputActionAsset asset { get; }
|
||||
public @MenuInput()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""name"": ""MenuInput"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""menu"",
|
||||
""id"": ""fddbd52a-f0f1-4589-8706-8a70d80fffc7"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Toggle"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""ad2f7940-95f2-4063-87a1-7d42f3791e9f"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""e4962cb0-d885-416a-a080-db19f4a0a4c4"",
|
||||
""path"": ""<Keyboard>/escape"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard&Mouse"",
|
||||
""action"": ""Toggle"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""a9401517-73d8-4cc5-baaa-56db81951850"",
|
||||
""path"": ""<Gamepad>/start"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Gamepad"",
|
||||
""action"": ""Toggle"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": [
|
||||
{
|
||||
""name"": ""Keyboard&Mouse"",
|
||||
""bindingGroup"": ""Keyboard&Mouse"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Keyboard>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
},
|
||||
{
|
||||
""devicePath"": ""<Mouse>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Gamepad"",
|
||||
""bindingGroup"": ""Gamepad"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Gamepad>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Touch"",
|
||||
""bindingGroup"": ""Touch"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Touchscreen>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""Joystick"",
|
||||
""bindingGroup"": ""Joystick"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<Joystick>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
""name"": ""XR"",
|
||||
""bindingGroup"": ""XR"",
|
||||
""devices"": [
|
||||
{
|
||||
""devicePath"": ""<XRController>"",
|
||||
""isOptional"": false,
|
||||
""isOR"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}");
|
||||
// menu
|
||||
m_menu = asset.FindActionMap("menu", throwIfNotFound: true);
|
||||
m_menu_Toggle = m_menu.FindAction("Toggle", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// menu
|
||||
private readonly InputActionMap m_menu;
|
||||
private List<IMenuActions> m_MenuActionsCallbackInterfaces = new List<IMenuActions>();
|
||||
private readonly InputAction m_menu_Toggle;
|
||||
public struct MenuActions
|
||||
{
|
||||
private @MenuInput m_Wrapper;
|
||||
public MenuActions(@MenuInput wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Toggle => m_Wrapper.m_menu_Toggle;
|
||||
public InputActionMap Get() { return m_Wrapper.m_menu; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(MenuActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IMenuActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_MenuActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_MenuActionsCallbackInterfaces.Add(instance);
|
||||
@Toggle.started += instance.OnToggle;
|
||||
@Toggle.performed += instance.OnToggle;
|
||||
@Toggle.canceled += instance.OnToggle;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IMenuActions instance)
|
||||
{
|
||||
@Toggle.started -= instance.OnToggle;
|
||||
@Toggle.performed -= instance.OnToggle;
|
||||
@Toggle.canceled -= instance.OnToggle;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IMenuActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_MenuActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IMenuActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_MenuActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_MenuActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public MenuActions @menu => new MenuActions(this);
|
||||
private int m_KeyboardMouseSchemeIndex = -1;
|
||||
public InputControlScheme KeyboardMouseScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_KeyboardMouseSchemeIndex == -1) m_KeyboardMouseSchemeIndex = asset.FindControlSchemeIndex("Keyboard&Mouse");
|
||||
return asset.controlSchemes[m_KeyboardMouseSchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_GamepadSchemeIndex = -1;
|
||||
public InputControlScheme GamepadScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_GamepadSchemeIndex == -1) m_GamepadSchemeIndex = asset.FindControlSchemeIndex("Gamepad");
|
||||
return asset.controlSchemes[m_GamepadSchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_TouchSchemeIndex = -1;
|
||||
public InputControlScheme TouchScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_TouchSchemeIndex == -1) m_TouchSchemeIndex = asset.FindControlSchemeIndex("Touch");
|
||||
return asset.controlSchemes[m_TouchSchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_JoystickSchemeIndex = -1;
|
||||
public InputControlScheme JoystickScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_JoystickSchemeIndex == -1) m_JoystickSchemeIndex = asset.FindControlSchemeIndex("Joystick");
|
||||
return asset.controlSchemes[m_JoystickSchemeIndex];
|
||||
}
|
||||
}
|
||||
private int m_XRSchemeIndex = -1;
|
||||
public InputControlScheme XRScheme
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_XRSchemeIndex == -1) m_XRSchemeIndex = asset.FindControlSchemeIndex("XR");
|
||||
return asset.controlSchemes[m_XRSchemeIndex];
|
||||
}
|
||||
}
|
||||
public interface IMenuActions
|
||||
{
|
||||
void OnToggle(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 337598c194bddae77922f951b35575d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
.radial-progress {
|
||||
min-width: 26px;
|
||||
min-height: 20px;
|
||||
--track-color: rgb(130, 130, 130);
|
||||
--progress-color: rgb(46, 132, 24);
|
||||
--percentage-color: white;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 5px;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.radial-progress__label {
|
||||
-unity-text-align: middle-left;
|
||||
color: var(--percentage-color);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22ecc27ec3f77ed128879fe6aa00c469
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class ShipUi : MonoBehaviour {
|
||||
[SerializeField]
|
||||
UIDocument uiDocument = null;
|
||||
|
||||
[SerializeField]
|
||||
ShipControls ship;
|
||||
|
||||
[SerializeField]
|
||||
Timing timing;
|
||||
|
||||
Label speed;
|
||||
Label timer;
|
||||
VisualElement sectors;
|
||||
VisualElement timeSheet;
|
||||
|
||||
void OnEnable() {
|
||||
speed = uiDocument.rootVisualElement.Q<Label>("speed");
|
||||
timer = uiDocument.rootVisualElement.Q<Label>("timer");
|
||||
sectors = uiDocument.rootVisualElement.Q<VisualElement>("sectors");
|
||||
timeSheet = uiDocument.rootVisualElement.Q<VisualElement>("timeSheet");
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
timer.text = $"{TimeSpan.FromSeconds(timing.lapTime):g}";
|
||||
speed.text = $"{ship.Speed():0} u/s";
|
||||
|
||||
// clearly this is not ideal but idk atm
|
||||
UpdateTimesheet();
|
||||
}
|
||||
|
||||
public void UpdateTimesheet() {
|
||||
if (sectors == null)
|
||||
Debug.LogWarning("null sectors");
|
||||
|
||||
timeSheet.Clear();
|
||||
foreach (Lap lap in timing.lapTimes) {
|
||||
Label l = new Label();
|
||||
l.text = $"{lap}";
|
||||
timeSheet.Add(l);
|
||||
}
|
||||
|
||||
sectors.Clear();
|
||||
|
||||
foreach (Sector sector in timing.sectors) {
|
||||
Label l = timing.sectorTimes
|
||||
.Where(s => s.Sector == sector.sector)
|
||||
.Select(s => {
|
||||
Label l = new Label($"{s}");
|
||||
string colourClass = timing.GetSectorColour(s).ToString().ToLowerInvariant();
|
||||
l.AddToClassList(colourClass);
|
||||
return l;
|
||||
})
|
||||
.DefaultIfEmpty(new Label("-"))
|
||||
.Single();
|
||||
|
||||
sectors.Add(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14d590d5e541e871cb4b472e9e009128
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
:root {
|
||||
--green: rgb(31, 240, 31);
|
||||
--red: rgb(165, 42, 42);
|
||||
--blue: rgb(48, 80, 248);
|
||||
--purple: rgb(164, 35, 188);
|
||||
--yellow: rgb(255, 161, 0);
|
||||
--white: rgb(245, 245, 245);
|
||||
color: var(--white);
|
||||
font-size: 24px;
|
||||
letter-spacing: 24px;
|
||||
unity-font: "Jura Medium";
|
||||
}
|
||||
|
||||
#list-entry {
|
||||
height: 41px;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
padding-left: 10px;
|
||||
background-color: rgb(170, 89, 57);
|
||||
border-color: rgb(49, 26, 17);
|
||||
border-width: 2px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
#character-name {
|
||||
-unity-font-style: bold;
|
||||
font-size: 18px;
|
||||
color: rgb(49, 26, 17);
|
||||
}
|
||||
|
||||
.green {
|
||||
color: var(--green);
|
||||
}
|
||||
|
||||
.purple {
|
||||
color: var(--purple);
|
||||
}
|
||||
|
||||
.red {
|
||||
color: var(--red);
|
||||
}
|
||||
|
||||
.yellow {
|
||||
color: var(--yellow);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf92f075876ddf7ffb4cd5c59633ad7b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
|
||||
disableValidation: 0
|
||||
Reference in new issue
Block a user