Created
May 21, 2015 20:05
-
-
Save Jon889/e7cb72addcaf7150ebdc to your computer and use it in GitHub Desktop.
Draggable runways and taxiways
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using ICities; | |
using ColossalFramework; | |
using ColossalFramework.Globalization; | |
using ColossalFramework.IO; | |
using ColossalFramework.UI; | |
using ColossalFramework.Steamworks; | |
using UnityEngine; | |
using System; | |
using System.Collections; | |
using System.Reflection; | |
using System.Collections.Generic; | |
using ColossalFramework.Plugins; | |
namespace MediumOWR | |
{ | |
public class MediumOWRMod : IUserMod | |
{ | |
public string Name | |
{ | |
get { return "Runways and Taxiways"; } | |
} | |
public string Description | |
{ | |
get { return "Adds draggable runways and taxiways to the game."; } | |
} | |
} | |
public class MediumOWRLoader : LoadingExtensionBase | |
{ | |
public override void OnCreated(ILoading loading) | |
{ | |
InitMod(); | |
} | |
public override void OnLevelLoaded(LoadMode mode) | |
{ | |
base.OnLevelLoaded(mode); | |
if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) | |
{ | |
InitMod(); | |
} | |
} | |
private void ShowNetwork(String name, String desc, GeneratedScrollPanel panel) | |
{ | |
var netInfo = PrefabCollection<NetInfo>.FindLoaded(name); | |
Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(SingletonLite<LocaleManager>.instance); | |
locale.AddLocalizedString(new Locale.Key() { m_Identifier = "NET_TITLE", m_Key = name }, name); | |
locale.AddLocalizedString(new Locale.Key() { m_Identifier = "NET_DESC", m_Key = name }, desc); | |
typeof(GeneratedScrollPanel).GetMethod("CreateAssetItem", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(panel, new object[] { netInfo }); | |
} | |
private void InitMod() | |
{ | |
PublicTransportPanel ptp = GameObject.Find("PublicTransportPlanePanel").GetComponent<PublicTransportPanel>(); | |
ShowNetwork("Airplane Runway", "Runway", ptp); | |
ShowNetwork("Airplane Taxiway", "Taxiway", ptp); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment