Created
April 13, 2015 22:58
-
-
Save Jon889/3da22b65d6cc6aec353f to your computer and use it in GitHub Desktop.
Custom Airports Cities Skylines
This file contains 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
namespace SomeRoads | |
{ | |
public class SomeRoadsLoader : 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 InitMod() | |
{ | |
float y = -0.40f; | |
createButton("Taxi", new Vector3(1.3f, y += 0.05f)); | |
createButton("Runway", new Vector3(1.3f, y += 0.05f)); | |
createButton("Line", new Vector3(1.3f, y += 0.05f)); | |
createButton("Path", new Vector3(1.3f, y += 0.05f)); | |
createButton("Connection Path", new Vector3(1.3f, y += 0.05f)); | |
createButton("Stop", new Vector3(1.3f, y += 0.05f)); | |
} | |
private void AirportButtonClicked(UIComponent component, UIMouseEventParameter eventParam) | |
{ | |
String text = (component as UIButton).text; | |
uint prefabindex = 19; | |
switch (text) | |
{ | |
case "Runway": | |
prefabindex = 18; | |
break; | |
case "Stop": | |
prefabindex = 20; | |
break; | |
case "Line": | |
prefabindex = 13; | |
break; | |
case "Path": | |
prefabindex = 14; | |
break; | |
case "Connection Path": | |
prefabindex = 15; | |
break; | |
} | |
NetTool tool = ToolsModifierControl.SetTool<NetTool>(); | |
if (tool != null) | |
{ | |
tool.m_prefab = PrefabCollection<NetInfo>.GetPrefab(prefabindex); ; | |
} | |
} | |
private UIButton createButton(String text, Vector3 position) | |
{ | |
var uiView = UIView.GetAView(); | |
var button = (UIButton)uiView.AddUIComponent(typeof(UIButton)); | |
button.text = text; | |
// Set the button dimensions. | |
button.width = 175; | |
button.height = 30; | |
button.transformPosition = position; | |
// Style the button to look like a menu button. | |
button.normalBgSprite = "ButtonMenu"; | |
button.disabledBgSprite = "ButtonMenuDisabled"; | |
button.hoveredBgSprite = "ButtonMenuHovered"; | |
button.focusedBgSprite = "ButtonMenuFocused"; | |
button.pressedBgSprite = "ButtonMenuPressed"; | |
button.textColor = new Color32(255, 255, 255, 255); | |
button.disabledTextColor = new Color32(7, 7, 7, 255); | |
button.hoveredTextColor = new Color32(7, 132, 255, 255); | |
button.focusedTextColor = new Color32(255, 255, 255, 255); | |
button.pressedTextColor = new Color32(30, 30, 44, 255); | |
// Enable button sounds. | |
button.playAudioEvents = true; | |
button.eventClick += AirportButtonClicked; | |
return button; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment