display radio station name

This commit is contained in:
in0finite 2020-05-05 17:45:06 +02:00
parent ea840f8b5e
commit 5237c849ba
3 changed files with 100 additions and 1 deletions

View file

@ -1763,6 +1763,8 @@ MonoBehaviour:
crosshairImage: {fileID: 5224926276646871215}
pedStateText: {fileID: 7285285471400155620}
pedVelocityText: {fileID: 6556768988591572453}
radioStationText: {fileID: 261304231076654976}
radioStationImage: {fileID: 0}
--- !u!1 &1693155584687832567
GameObject:
m_ObjectHideFlags: 0
@ -4651,7 +4653,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -104.99988, y: -224}
m_AnchoredPosition: {x: -105, y: -224}
m_SizeDelta: {x: 190, y: 25}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3535806125381433082
@ -7627,6 +7629,7 @@ RectTransform:
- {fileID: 2587223306693521120}
- {fileID: 7544529063945659150}
- {fileID: 2222193836290576247}
- {fileID: 122172316996072528}
m_Father: {fileID: 5719983600610341389}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -8125,6 +8128,85 @@ MonoBehaviour:
m_FlexibleWidth: -1
m_FlexibleHeight: 48
m_LayoutPriority: 1
--- !u!1 &8569074166000735776
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 122172316996072528}
- component: {fileID: 2203872922477210907}
- component: {fileID: 261304231076654976}
m_Layer: 0
m_Name: RadioStationLabel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &122172316996072528
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8569074166000735776}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 7060217674643716524}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -25}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2203872922477210907
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8569074166000735776}
m_CullTransparentMesh: 0
--- !u!114 &261304231076654976
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8569074166000735776}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.7169812, g: 0.55353504, b: 0.19953722, a: 1}
m_RaycastTarget: 0
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 20
m_FontStyle: 1
m_BestFit: 0
m_MinSize: 1
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Station Name
--- !u!1 &8607493305112772351
GameObject:
m_ObjectHideFlags: 0

View file

@ -8,6 +8,7 @@ namespace SanAndreasUnity.Behaviours.Vehicles
public class RadioStation
{
private static readonly string[] streams = { "CH", "CO", "CR", "DS", "HC", "MH", "MR", "NJ", "RE", "RG", "TK" };
public static readonly string[] StationNames = { "PlayBack FM", "KRose", "K-DST", "Bounce FM", "SFUR", "Radio Los Santos", "Radio X", "CSR", "K-Jah", "Master Sounds", "WCTR" };
private static readonly int startIndex = 3;
private static readonly int endIndex = 114;

View file

@ -4,6 +4,7 @@ using SanAndreasUnity.Behaviours;
using SanAndreasUnity.Utilities;
using UnityEngine.UI;
using SanAndreasUnity.Importing.Conversion;
using SanAndreasUnity.Behaviours.Vehicles;
namespace SanAndreasUnity.UI {
@ -19,6 +20,8 @@ namespace SanAndreasUnity.UI {
public RawImage crosshairImage;
public Text pedStateText;
public Text pedVelocityText;
public Text radioStationText;
public RawImage radioStationImage;
public static Texture2D LeftArrowTexture { get; set; }
public static Texture2D RightArrowTexture { get; set; }
@ -149,6 +152,19 @@ namespace SanAndreasUnity.UI {
this.pedVelocityText.text = pedVelocityDisplayText;
}
var vehicle = ped.CurrentVehicle;
if (vehicle != null)
{
string text = vehicle.CurrentRadioStationIndex >= 0 ? RadioStation.StationNames[vehicle.CurrentRadioStationIndex] : "Radio Off";
if (this.radioStationText.text != text)
this.radioStationText.text = text;
}
else
{
if (this.radioStationText.text != "")
this.radioStationText.text = "";
}
}
}