internal override void Awake() { WindowCaption = "Contract Configuration"; WindowRect = new Rect(40, 80, 780, 360); WindowStyle = contractSkins.newWindowStyle; Visible = false; DragEnabled = true; TooltipMouseOffset = new Vector2d(-10, -25); //Make sure our click-through control locks are disabled InputLockManager.RemoveControlLock(lockID); DMC_SkinsLibrary.SetCurrent("ContractUnitySkin"); }
/// <summary> /// Unity: OnGUI is called for rendering and handling GUI events. /// /// Trigger: This is called multiple times per frame to lay stuff out etc. /// Code here ignores the F2 key that disables user interface. So if you are making something to be user hidable then use the RenderingManager.PostDrawQueue functions in here /// Alternatively you could use the MonoBehaviourWindow Type and its DrawWindow Function /// </summary> private void OnGUI() { if (!_OnGUIOnceOnlyHasRun) { //set theflag so this only runs once _OnGUIOnceOnlyHasRun = true; //set up the skins library if (!DMC_SkinsLibrary._Initialized) { DMC_SkinsLibrary.InitSkinList(); } //then pass it on to the downstream derivatives OnGUIOnceOnly(); } OnGUIEvery(); }
internal static void initializeSkins() { //Initialize Skins contractKSPSkin = DMC_SkinsLibrary.CopySkin(DMC_SkinsLibrary.DefSkinType.KSP); contractKSPSkin.button = DMC_SkinsLibrary.DefKSPSkin.button; DMC_SkinsLibrary.AddSkin("ContractKSPSkin", contractKSPSkin); contractUnitySkin = DMC_SkinsLibrary.CopySkin(DMC_SkinsLibrary.DefSkinType.Unity); DMC_SkinsLibrary.AddSkin("ContractUnitySkin", contractUnitySkin); //Main Window Style newWindowStyle = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.window); newWindowStyle.name = "WindowStyle"; newWindowStyle.fontSize = 14 + normalFontSize + windowFontSize; newWindowStyle.padding = new RectOffset(0, 1, 20, 12); newWindowStyle.normal.background = windowTex; newWindowStyle.focused.background = newWindowStyle.normal.background; newWindowStyle.onNormal.background = newWindowStyle.normal.background; //Contract Title Style contractActive = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.button); contractActive.name = "ContractActiveText"; contractActive.fontSize = 12 + normalFontSize + windowFontSize; contractActive.alignment = TextAnchor.UpperLeft; contractActive.normal.textColor = XKCDColors.DustyOrange; contractActive.wordWrap = true; contractActive.margin = new RectOffset(1, 3, 2, 2); contractActiveBehind = new GUIStyle(contractActive); contractActiveBehind.name = "ContractActiveTextBehind"; contractActiveBehind.hover.background = contractActiveBehind.normal.background; contractActiveBehind.hover.textColor = contractActiveBehind.normal.textColor; contractCompleted = new GUIStyle(contractActive); contractCompleted.name = "ContractCompleteText"; contractCompleted.normal.textColor = XKCDColors.FreshGreen; contractCompletedBehind = new GUIStyle(contractCompleted); contractCompletedBehind.name = "ContractCompletedTextBehind"; contractCompletedBehind.hover.background = contractCompletedBehind.normal.background; contractCompletedBehind.hover.textColor = contractCompletedBehind.normal.textColor; contractFailed = new GUIStyle(contractActive); contractFailed.name = "ContractFailedText"; contractFailed.normal.textColor = XKCDColors.Red; contractFailedBehind = new GUIStyle(contractFailed); contractFailedBehind.name = "ContractFailedTextBehind"; contractFailedBehind.hover.background = contractFailedBehind.normal.background; contractFailedBehind.hover.textColor = contractFailedBehind.normal.textColor; //Parameter Style paramText = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); paramText.name = "ParameterText"; paramText.fontSize = 11 + normalFontSize + windowFontSize; paramText.normal.textColor = XKCDColors.PaleGrey; paramText.wordWrap = true; paramText.alignment = TextAnchor.UpperLeft; paramSub = new GUIStyle(paramText); paramSub.name = "ParamSubText"; paramSub.normal.textColor = XKCDColors.LightGrey; paramCompleted = new GUIStyle(paramText); paramCompleted.name = "ParameterCompleteText"; paramCompleted.normal.textColor = XKCDColors.FreshGreen; paramFailed = new GUIStyle(paramText); paramFailed.name = "ParameterFailedText"; paramFailed.normal.textColor = XKCDColors.Red; //Note Style noteText = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); noteText.name = "ContractNoteText"; noteText.fontSize = 11 + normalFontSize + windowFontSize; noteText.wordWrap = true; noteText.alignment = TextAnchor.UpperLeft; noteText.normal.textColor = XKCDColors.AquaBlue; //Expanded Style timerGood = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); timerGood.name = "TimerGood"; timerGood.fontSize = 11 + normalFontSize + windowFontSize; timerGood.normal.textColor = XKCDColors.FreshGreen; timerGood.wordWrap = false; timerGood.alignment = TextAnchor.UpperCenter; timerGood.padding = new RectOffset(1, 1, 1, 2); timerBad = new GUIStyle(timerGood); timerBad.name = "TimerBad"; timerBad.normal.textColor = XKCDColors.VomitYellow; timerFinished = new GUIStyle(timerGood); timerFinished.name = "TimerFinished"; timerFinished.normal.textColor = XKCDColors.Red; reward = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); reward.name = "FundsReward"; reward.fontSize = 10 + normalFontSize + windowFontSize; reward.normal.textColor = XKCDColors.FreshGreen; reward.wordWrap = false; reward.alignment = TextAnchor.MiddleLeft; penalty = new GUIStyle(reward); penalty.name = "FundsPenalty"; penalty.normal.textColor = XKCDColors.OrangeyRed; texLabel = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); texLabel.name = "TexLabel"; texLabel.padding = new RectOffset(0, 0, 0, 0); scienceReward = new GUIStyle(reward); scienceReward.name = "ScienceReward"; scienceReward.normal.textColor = XKCDColors.AquaBlue; scienceReward.padding = new RectOffset(1, 1, 1, 3); //Other Styles dropDown = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.box); dropDown.name = "DropDown"; dropDown.normal.background = dropDownTex; sortMenu = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); sortMenu.name = "SortMenu"; sortMenu.fontSize = 12 + normalFontSize + windowFontSize; sortMenu.padding = new RectOffset(2, 2, 2, 2); sortMenu.normal.textColor = XKCDColors.White; sortMenu.hover.textColor = XKCDColors.AlmostBlack; Texture2D sortBackground = new Texture2D(1, 1); sortBackground.SetPixel(1, 1, XKCDColors.OffWhite); sortBackground.Apply(); sortMenu.hover.background = sortBackground; sortMenu.alignment = TextAnchor.MiddleLeft; texButton = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.button); texButton.name = "TexButton"; texButton.normal.background = DMC_SkinsLibrary.DefUnitySkin.label.normal.background; texButton.hover.background = buttonHover; texButton.padding = new RectOffset(1, 1, 2, 2); texButtonSmall = new GUIStyle(texButton); texButtonSmall.name = "TexButtonSmall"; texButtonSmall.padding = new RectOffset(1, 1, 1, 1); dragButton = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); dragButton.name = "DragButton"; dragButton.padding = new RectOffset(1, 2, 0, 0); resetBox = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); resetBox.name = "ResetBox"; resetBox.fontSize = 16; resetBox.normal.textColor = XKCDColors.VomitYellow; resetBox.wordWrap = true; resetBox.alignment = TextAnchor.UpperCenter; resetButton = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.button); resetButton.name = "ResetButton"; resetButton.fontSize = 15; resetButton.alignment = TextAnchor.MiddleCenter; agentName = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); agentName.name = "AgentName"; agentName.normal.textColor = XKCDColors.White; agentName.fontSize = 13 + normalFontSize + windowFontSize; agentName.fontStyle = FontStyle.Bold; agentName.wordWrap = true; agentName.alignment = TextAnchor.MiddleCenter; agentBackground = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.box); agentBackground.name = "AgentBackground"; Texture2D agentBackDrop = new Texture2D(1, 1); agentBackDrop.SetPixel(1, 1, XKCDColors.White); agentBackDrop.Apply(); agentBackground.normal.background = agentBackDrop; //Config styles smallLabel = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); smallLabel.name = "SmallLabel"; smallLabel.fontSize = 10; smallLabel.normal.textColor = Color.white; configDropMenu = new GUIStyle(sortMenu); configDropMenu.name = "ConfigDropMenu"; configDropMenu.fontSize = 12 + normalFontSize; configDropMenu.wordWrap = false; configDropDown = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.button); configDropDown.name = "ConfigDropDown"; configDropDown.fontSize = 16 + normalFontSize; configDropDown.normal.textColor = XKCDColors.DustyOrange; configDropDown.alignment = TextAnchor.MiddleCenter; configHeader = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); configHeader.name = "ConfigHeader"; configHeader.fontSize = 16 + normalFontSize; configHeader.normal.textColor = XKCDColors.DustyOrange; configHeader.alignment = TextAnchor.MiddleLeft; configClose = new GUIStyle(texButton); configClose.name = "ConfigClose"; configClose.normal.textColor = XKCDColors.DustyOrange; configLabel = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.label); configLabel.name = "ConfigLabel"; configLabel.alignment = TextAnchor.MiddleRight; configLabel.fontSize = 12 + normalFontSize; configButton = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.button); configButton.name = "ConfigButton"; configButton.fontSize = 12 + normalFontSize; configToggle = new GUIStyle(DMC_SkinsLibrary.DefUnitySkin.toggle); configToggle.name = "ConfigToggle"; configToggle.fontSize = 12 + normalFontSize; configCenterLabel = new GUIStyle(configLabel); configCenterLabel.name = "ConfigCenterLabel"; configCenterLabel.alignment = TextAnchor.MiddleCenter; //Add skins and styles to the library DMC_SkinsLibrary.List["ContractUnitySkin"].window = new GUIStyle(newWindowStyle); DMC_SkinsLibrary.List["ContractUnitySkin"].button = new GUIStyle(texButton); DMC_SkinsLibrary.List["ContractUnitySkin"].box = new GUIStyle(noteText); DMC_SkinsLibrary.List["ContractUnitySkin"].label = new GUIStyle(texLabel); DMC_SkinsLibrary.AddStyle("ContractUnitySkin", newWindowStyle); DMC_SkinsLibrary.AddStyle("ContractUnitySkin", texButton); DMC_SkinsLibrary.AddStyle("ContractUnitySkin", noteText); DMC_SkinsLibrary.AddStyle("ContractUnitySkin", texLabel); }