private void SetVersionControlSystem(object data) { int popupIndex = (int)data; if (popupIndex < 0 && popupIndex >= vcPopupList.Length) { return; } PopupElement el = vcPopupList[popupIndex]; string oldVC = EditorSettings.externalVersionControl; EditorSettings.externalVersionControl = el.id; Provider.UpdateSettings(); AssetDatabase.Refresh(); if (oldVC != el.id) { if (el.content.text == ExternalVersionControl.Disabled || el.content.text == ExternalVersionControl.Generic ) { // Close the normal version control window WindowPending.CloseAllWindows(); } } }
public void ItemBought(PopupElement newPopupElement) { CampaignManager.BuyItem(newPopupElement.characterType, newPopupElement.characterId, newPopupElement.teamId); this.panel_Shop.GetComponent <ShopPanel> ().Init(); this.panel_Shop.GetComponent <ShopPanel> ().ItemBought(newPopupElement); this.HidePopup(7); }
public void ActionBought(PopupElement newPopupElement) { CampaignManager.ChangePlayerAction(newPopupElement.characterType, newPopupElement.characterId, newPopupElement.teamId); this.panel_Shop.GetComponent <ShopPanel> ().Init(); this.panel_Shop.GetComponent <ShopPanel> ().CardBought(newPopupElement); this.HidePopup(7); }
private void addPresetLine(float preset) { PopupElement element = new PopupElement(axis, preset.ToString(), new PopupButton("Use", 0f, setTrimValue)); element.buttons[0].popupElement = element; popup.sections[0].elements.Add(element); }
public void ItemBought(PopupElement newPopupElement) { if (newPopupElement.characterType == 1) { this.GenerateSummonerPanel(CampaignManager.playerTeam.mainSummoner); } else { this.GenerateSupportPanel(CampaignManager.playerTeam.supports [newPopupElement.characterId], newPopupElement.characterId); } }
private void PopupBase(PopupElement button, UnityAction confirmationEvent = null, UnityAction cancelEvent = null) { Popup(); button.gameObject.SetActive(true); if (confirmationEvent != null) { button.confirmButton.onClick.AddListener(confirmationEvent); } if (cancelEvent != null) { button.cancelButton.onClick.AddListener(cancelEvent); } }
//public List<PopupElement> elementList = new List<PopupElement>(); //private string currentOptionString; /// <summary> /// Create the editor popup adn define its settings. Example use at the end of this modules' source. /// </summary> /// <param name="part">The calling part, just use this.part</param> /// <param name="module">The class name of the module where this is being used</param> /// <param name="ID">If you have more than one of a module on a part the ID should be unique to prevent window stealing and overlap. Should be passed on from the cfg.</param> /// <param name="Windowlayer">the GUI windows layer. Should be unique for each class, possibly with a span of numbers reserved for duplicate modules. the final layer used is layer + ID</param> /// <param name="windowDimensions">Left, Top, Width and Height of the GUI window. These are not static, but changed by dragging the window and by resizing functions.</param> public FSGUIPopup(Part part, string module, int ID, int Windowlayer, Rect windowDimensions, string windowName, PopupElement defaultElement) { sections = new List<PopupSection>(); sections.Add(new PopupSection()); sections[0].elements.Add(defaultElement); //elementList.Add(defaultElement); parentPart = part; moduleName = module; moduleID = ID; GUIlayer = Windowlayer; windowRect = windowDimensions; windowTitle = windowName; windowRect.y += (moduleID * windowRect.height) + 20; }
public void GenerateCharactersPopup() { SummonerData[] summoners = JsonSave.LoadSummoners(); SummonerData[] enemies = JsonSave.LoadEnemies(); SupportData[] supports = JsonSave.LoadSupports(); for (int i = 0; i < summoners.Length; i++) { GameObject summonerElementTemp = Instantiate(this.characterElementPrefab, this.transform.GetChild(2).position, this.transform.rotation, this.transform.GetChild(2).GetChild(0)) as GameObject; PopupElement summonerElementScript = summonerElementTemp.GetComponent <PopupElement> (); summonerElementTemp.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("character_avatars/" + summoners [i].idAvatar); summonerElementTemp.transform.GetChild(1).GetComponent <Text> ().text = summoners [i].summonerName; summonerElementTemp.name = summoners [i].summonerName; summonerElementScript.summoner = summoners [i]; summonerElementScript.characterType = 1; summonerElementScript.characterId = summoners [i].id; } for (int i = 0; i < enemies.Length; i++) { GameObject summonerElementTemp = Instantiate(this.characterElementPrefab, this.transform.GetChild(2).position, this.transform.rotation, this.transform.GetChild(2).GetChild(0)) as GameObject; PopupElement summonerElementScript = summonerElementTemp.GetComponent <PopupElement> (); summonerElementTemp.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("character_avatars/" + enemies [i].idAvatar); summonerElementTemp.transform.GetChild(1).GetComponent <Text> ().text = enemies [i].summonerName; summonerElementTemp.name = enemies [i].summonerName; summonerElementScript.summoner = enemies [i]; summonerElementScript.characterType = 3; summonerElementScript.characterId = enemies [i].id; } for (int i = 0; i < supports.Length; i++) { GameObject summonerElementTemp = Instantiate(this.characterElementPrefab, this.transform.GetChild(2).position, this.transform.rotation, this.transform.GetChild(2).GetChild(0)) as GameObject; PopupElement summonerElementScript = summonerElementTemp.GetComponent <PopupElement> (); summonerElementTemp.transform.GetChild(0).GetChild(0).GetComponent <Image>().sprite = Resources.Load <Sprite> ("character_avatars/" + supports [i].idAvatar); summonerElementTemp.transform.GetChild(1).GetComponent <Text> ().text = supports [i].supportName; summonerElementTemp.name = supports [i].supportName; summonerElementScript.support = supports [i]; summonerElementScript.characterType = 2; summonerElementScript.characterId = supports [i].id; } }
private void DoPopup(Rect popupRect, PopupElement[] elements, int selectedIndex, GenericMenu.MenuFunction2 func) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < elements.Length; i++) { PopupElement element = elements[i]; if (element.Enabled) { menu.AddItem(element.content, i == selectedIndex, func, i); } else { menu.AddDisabledItem(element.content); } } menu.DropDown(popupRect); }
//private void setLaunchEventText() //{ // if (moveAtLaunch) // { // Events["toggleMoveAtLaunchEvent"].guiName = "Launch on runway"; // } // else // { // Events["toggleMoveAtLaunchEvent"].guiName = "Launch in water"; // } //} public override void OnStart(PartModule.StartState state) { //setLaunchEventText(); if (HighLogic.LoadedSceneIsFlight) { windowID = FSGUIwindowID.getNextID(); fileNameElement = new PopupElement("Name", "New"); PopupElement saveButtonElement = new PopupElement(new PopupButton("Save", 0f, savePositionToFile)); saveButtonElement.buttons.Add(new PopupButton("Cancel", 0f, cancelSave)); popup = new FSGUIPopup(part, "FSmoveCraftAtLaunch", 0, windowID, FSGUIwindowID.standardRect, "Save Position", fileNameElement); popup.sections[0].elements.Add(saveButtonElement); popup.showCloseButton = true; popup.useInEditor = false; popup.useInActionEditor = false; popup.useInFlight = true; } files = Directory.GetFiles(Firespitter.Tools.PlugInDataPath, "*.pos"); }
public void AddEmptyPanel(int newTeamId, int newCharacterType) { if (newTeamId == 1) { GameObject characterInfosTemp = Instantiate(this.emptyInfosPanelPrefab, this.supportTeamContainer.transform.position, this.transform.rotation, this.supportTeamContainer.transform) as GameObject; //CharacterPanelEditor characterInfosScript = characterInfosTemp.GetComponent<CharacterPanelEditor> (); //characterInfosScript.teamId = 1; PopupElement characterElementScript = characterInfosTemp.GetComponent <PopupElement> (); characterElementScript.teamId = newTeamId; characterElementScript.characterType = newCharacterType; } else { GameObject characterInfosTemp = Instantiate(this.monsterEmptyInfosPanelPrefab, this.enemyTeamContainer.transform.position, this.transform.rotation, this.enemyTeamContainer.transform) as GameObject; //CharacterPanelEditor characterInfosScript = characterInfosTemp.GetComponent<CharacterPanelEditor> (); //characterInfosScript.teamId = 1; PopupElement characterElementScript = characterInfosTemp.GetComponent <PopupElement> (); characterElementScript.teamId = newTeamId; characterElementScript.characterType = newCharacterType; } }
public override void OnStart(PartModule.StartState state) { base.OnStart(state); if (popupWindowID == 0) popupWindowID = FSGUIwindowID.getNextID(); firstPresetLine = 1; PopupElement element = new PopupElement(new PopupButton("+", 25f, adjustTrimFromButton)); element.buttons.Add(new PopupButton("-", 25f, adjustTrimFromButton)); element.buttons.Add(new PopupButton("Add", 43f, addPresetLine)); element.buttons.Add(new PopupButton("Del", 43f, removePresetLine)); popup = new FSGUIPopup(part, "FStrimAdjustment", moduleID, popupWindowID, new Rect(100f, 200f, 180f, 150f), axis + " Trim Adjustment", element);//FSGUIwindowID.trimAdjustment + moduleID if (HighLogic.LoadedSceneIsEditor) { //popup.showMenu = true; elementShowOnFlightStart = new PopupElement("Show on Launch?", new PopupButton("Y", "N", 30f, toggleShowOnFlightStart)); elementShowOnFlightStart.titleSize = 120f; popup.sections[0].elements.Add(elementShowOnFlightStart); elementShowOnFlightStart.buttons[0].toggle(showOnFlightStart); firstPresetLine = 2; } else { if (HighLogic.LoadedSceneIsFlight && showOnFlightStart) { popup.showMenu = true; } else { popup.showMenu = false; } } popup.useInFlight = false; popup.useInEditor = true; //popup.useInActionEditor = true; addPresetLine(presetTrim0); if (presetTrim1 != 0f) addPresetLine(presetTrim1); if (presetTrim2 != 0f) addPresetLine(presetTrim2); if (HighLogic.LoadedSceneIsEditor) { popup.windowRect.x = 450f; } Actions["togglePopupAction"].guiName = "Toggle " + axis + " Popup"; Actions["usePreset1Action"].guiName = "Use " + axis + " Preset 1"; Events["togglePopupEvent"].guiName = "Toggle " + axis + " Popup"; Actions["increaseTrimAction"].guiName = axis + " trim + 1 step"; Actions["decreaseTrimAction"].guiName = axis + " trim - 1 step"; Actions["increaseTrimMoreAction"].guiName = "" + axis + " trim +" + MoreTrimActionMultiplier + " steps"; Actions["decreaseTrimMoreAction"].guiName = "" + axis + " trim -" + MoreTrimActionMultiplier + " steps"; }
public void AddElement(PopupElement element) { elements.Add(element); }
public override void OnStart(PartModule.StartState state) { try { deploymentStateEnum = (DeploymentStates)Enum.Parse(typeof(DeploymentStates), deploymentState); } catch { Log.dbg("FSwheel: Could not set deployment state {0}", deploymentState); } #region animation anim = part.FindModelAnimators(animationName).FirstOrDefault(); if (anim != null) { hasAnimation = true; anim[animationName].layer = animationLayer; float startAnimTime = 0f; if (deploymentStateEnum == DeploymentStates.Retracted) { startAnimTime = 1f; animSpeed = 1f * customAnimationSpeed; } else { animSpeed = -1f * customAnimationSpeed; } anim[animationName].normalizedTime = startAnimTime; anim[animationName].speed = animSpeed; anim.Play(animationName); } #endregion #region In flight if (HighLogic.LoadedSceneIsFlight) { #region create wheel setup List <WheelCollider> colliderList = new List <WheelCollider>(); List <Transform> wheelMeshList = new List <Transform>(); List <Transform> suspensionList = new List <Transform>(); for (int i = 0; i < numberOfWheels; i++) { string suffix = (i + 1).ToString(); // the names used are e.g. "Wheel", "Wheel2", "Wheel3", to remain compatible with stock wheels if (i == 0) { suffix = ""; } Transform colliderTransform = part.FindModelTransform(wheelColliderName + suffix); if (colliderTransform != null) { WheelCollider collider = colliderTransform.GetComponent <WheelCollider>(); if (collider != null) { colliderList.Add(collider); Transform wheelMeshTransform = part.FindModelTransform(wheelMeshName + suffix); if (wheelMeshTransform != null) { wheelMeshList.Add(wheelMeshTransform); } else { Log.info("FSwheel: missing wheel mesh {0}{1}", wheelMeshName, suffix); } Transform suspensionTransform = part.FindModelTransform(suspensionParentName + suffix); if (suspensionTransform != null) { suspensionList.Add(suspensionTransform); } else { Log.info("FSwheel: missing suspensionParent {0}{1}", suspensionParentName, suffix); } } } else { Log.info("FSwheel: missing wheel collider {0}{1}", wheelColliderName, suffix); } } wheelList.Create(colliderList, wheelMeshList, suspensionList); if (wheelList != null) { if (!wheelList.enabled) { wheelList.enabled = true; } } // set the motor direction based on the first found wheelColliders orientation Log.dbg("FSwheel: wheelist count is {0}", wheelList.wheels.Count); if (wheelList.wheels.Count > 0) { Log.info("FSwheel: reversemotorset: {0}", reverseMotorSet); if (!reverseMotorSet) //run only the first time the craft is loaded { float dot = Vector3.Dot(wheelList.wheels[0].wheelCollider.transform.forward, vessel.ReferenceTransform.up); // up is forward if (dot < 0) // below 0 means the engine is on the left side of the craft { reverseMotor = true; Log.dbg("FSwheel: Reversing motor, dot: {0}", dot); } else { reverseMotor = false; Log.dbg("FSwheel: Motor reversing skipped, dot: {0}", dot); } if (motorStartsReversed) { reverseMotor = !reverseMotor; } reverseMotorSet = true; } } if (disableColliderWhenRetracted) { if (deploymentStateEnum == DeploymentStates.Retracted) { wheelList.enabled = false; } } //friction override if (overrideModelFrictionValues) { wheelList.forwardStiffness = forwardsStiffness; wheelList.forwardsAsymptoteSlip = forwardsAsymptoteSlip; wheelList.forwardsAsymptoteValue = forwardsAsymptoteValue; wheelList.forwardsExtremumSlip = forwardsExtremumSlip; wheelList.forwardsExtremumValue = forwardsExtremumValue; wheelList.sidewaysStiffness = sidewaysStiffness; wheelList.sidewaysAsymptoteSlip = sidewaysAsymptoteSlip; wheelList.sidewaysAsymptoteValue = sidewaysAsymptoteValue; wheelList.sidewaysExtremumSlip = sidewaysExtremumSlip; wheelList.sidewaysExtremumValue = sidewaysExtremumValue; wheelList.updateWheelFriction(); } //optionally set collider and spring values if ((suspensionSpring >= 0f && suspensionDamper >= 0f && suspensionTargetPosition >= 0f) || overrideModelSpringValues) { wheelList.updateSpring(suspensionSpring, suspensionDamper, suspensionTargetPosition); } if (wheelColliderRadius >= 0f) { wheelList.radius = wheelColliderRadius; } else { wheelColliderRadius = wheelList.radius; } if (wheelColliderMass >= 0f) { wheelList.mass = wheelColliderMass; } if (wheelColliderSuspensionDistance >= 0f || overrideSuspensionDistance) { wheelList.suspensionDistance = wheelColliderSuspensionDistance; } else { wheelColliderSuspensionDistance = wheelList.suspensionDistance; } #endregion #region GUI popup popup = new FSGUIPopup(part, "FSwheel", moduleID, FSGUIwindowID.wheel, new Rect(500f, 300f, 250f, 100f), "Wheel settings", new PopupElement("Suspension Settings:")); popup.useInFlight = true; wheelRadiusElement = new PopupElement("Radius", wheelColliderRadius.ToString()); suspensionDistanceElement = new PopupElement("Distance", wheelColliderSuspensionDistance.ToString()); suspensionSpringElement = new PopupElement("Spring", suspensionSpring.ToString()); suspensionDamperElement = new PopupElement("Damper", suspensionDamper.ToString()); suspensionTargetPositionElement = new PopupElement("Target pos", suspensionTargetPosition.ToString()); popup.sections[0].elements.Add(wheelRadiusElement); popup.sections[0].elements.Add(suspensionDistanceElement); popup.sections[0].elements.Add(suspensionSpringElement); popup.sections[0].elements.Add(suspensionDamperElement); popup.sections[0].elements.Add(suspensionTargetPositionElement); suspensionUpdateElement = new PopupElement(new PopupButton("Update", 0f, popupUpdateSuspension)); popup.sections[0].elements.Add(suspensionUpdateElement); #endregion if (brakeEmissiveObjectName != string.Empty) { brakeEmissiveObject = part.FindModelTransform(brakeEmissiveObjectName); } setBrakeLight(brakesEngaged); #region set up fx if (useCustomParticleFX) { smokeFXtexture = GameDatabase.Instance.GetTexture(smokeFXtextureName, false); if (smokeFXtexture == null) { useCustomParticleFX = false; } else { for (int i = 0; i < wheelList.wheels.Count; i++) { wheelList.wheels[i].smokeFX = new Firespitter.FSparticleFX(wheelList.wheels[i].fxLocation, smokeFXtexture); wheelList.wheels[i].smokeFX.AnimatorColor0 = new Color(1.0f, 1.0f, 1.0f, 0.8f); wheelList.wheels[i].smokeFX.AnimatorColor1 = new Color(1.0f, 1.0f, 1.0f, 0.5f); wheelList.wheels[i].smokeFX.AnimatorColor2 = new Color(1.0f, 1.0f, 1.0f, 0.2f); wheelList.wheels[i].smokeFX.AnimatorColor3 = new Color(1.0f, 1.0f, 1.0f, 0.1f); wheelList.wheels[i].smokeFX.AnimatorColor4 = new Color(1.0f, 1.0f, 1.0f, 0.0f); wheelList.wheels[i].smokeFX.EmitterMinSize = 0.3f; wheelList.wheels[i].smokeFX.EmitterMaxSize = 0.5f; wheelList.wheels[i].smokeFX.EmitterMinEnergy = 0.1f; wheelList.wheels[i].smokeFX.EmitterMaxEnergy = 0.3f; wheelList.wheels[i].smokeFX.EmitterMinEmission = 0f; wheelList.wheels[i].smokeFX.EmitterMaxEmission = 0f; wheelList.wheels[i].smokeFX.AnimatorSizeGrow = 0.1f; wheelList.wheels[i].smokeFX.setupFXValues(); } } } #endregion } #endregion #region GUI element changes Events["RaiseGear"].guiActiveUnfocused = guiActiveUnfocused; Events["RaiseGear"].unfocusedRange = unfocusedRange; Events["LowerGear"].guiActiveUnfocused = guiActiveUnfocused; Events["LowerGear"].unfocusedRange = unfocusedRange; Events["EnableMotorEvent"].guiActive = !motorEnabled; Events["DisableMotorEvent"].guiActive = motorEnabled; Events["EnableMotorEvent"].guiActiveEditor = !motorEnabled; Events["DisableMotorEvent"].guiActiveEditor = motorEnabled; Events["brakesOnEvent"].guiActive = !brakesEngaged; Events["brakesOffEvent"].guiActive = brakesEngaged; Events["brakesOnEvent"].guiActiveEditor = !brakesEngaged; Events["brakesOffEvent"].guiActiveEditor = brakesEngaged; Events["EnableReverseMotorEvent"].guiActive = !reverseMotor; Events["DisableReverseMotorEvent"].guiActive = reverseMotor; Events["EnableReverseMotorEvent"].guiActiveEditor = !reverseMotor; Events["DisableReverseMotorEvent"].guiActiveEditor = reverseMotor; Events["brakesOnEvent"].guiActiveUnfocused = guiActiveUnfocused; Events["brakesOffEvent"].guiActiveUnfocused = guiActiveUnfocused; if (!hasMotor) { //Events["EnableMotorEvent"].guiActive = false; //Events["DisableMotorEvent"].guiActive = false; Events["EnableMotorEvent"].active = false; Events["DisableMotorEvent"].active = false; Events["EnableReverseMotorEvent"].active = false; Events["DisableReverseMotorEvent"].active = false; } if (!hasAnimation) { Events["RaiseGear"].active = false; Events["LowerGear"].active = false; } if (debugMode) { Events["increaseFrictionEvent"].guiActive = true; Events["decreaseFrictionEvent"].guiActive = true; Events["suspensionGUIEvent"].guiActive = true; } if (brakesLockedOn) { Events["brakesOnEvent"].guiActive = false; Events["brakesOffEvent"].guiActive = false; Events["brakesOnEvent"].guiActiveUnfocused = false; Events["brakesOffEvent"].guiActiveUnfocused = false; } #endregion }
//public List<PopupElement> elementList = new List<PopupElement>(); //private string currentOptionString; /// <summary> /// Create the editor popup adn define its settings. Example use at the end of this modules' source. /// </summary> /// <param name="part">The calling part, just use this.part</param> /// <param name="module">The class name of the module where this is being used</param> /// <param name="ID">If you have more than one of a module on a part the ID should be unique to prevent window stealing and overlap. Should be passed on from the cfg.</param> /// <param name="Windowlayer">the GUI windows layer. Should be unique for each class, possibly with a span of numbers reserved for duplicate modules. the final layer used is layer + ID</param> /// <param name="windowDimensions">Left, Top, Width and Height of the GUI window. These are not static, but changed by dragging the window and by resizing functions.</param> public FSGUIPopup(Part part, string module, int ID, int Windowlayer, Rect windowDimensions, string windowName, PopupElement defaultElement) { sections = new List <PopupSection>(); sections.Add(new PopupSection()); sections[0].elements.Add(defaultElement); //elementList.Add(defaultElement); parentPart = part; moduleName = module; moduleID = ID; GUIlayer = Windowlayer; windowRect = windowDimensions; windowTitle = windowName; windowRect.y += (moduleID * windowRect.height) + 20; }
public void AddElement(PopupElement element, float height) { element.height = height; elements.Add(element); }
private void drawElement(PopupElement element) { if (element.showElement) { if (element.style == null) { element.setStyle(GUI.skin.textArea); //GUI.skin.textArea } int activeElements = 0; if (element.useTitle) { activeElements++; } if (element.useInput) { activeElements++; } activeElements += element.buttons.Count; if (activeElements < 1) { return; } Rect subElementRect = new Rect(marginLeft, marginTop + lastSectionTop + lastElementTop, element.titleSize, element.height); if (element.useTitle) { if (subElementRect.width == 0) { subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); } if (element.useTextArea) { GUI.TextArea(subElementRect, element.titleText, element.style); } else { GUI.Label(subElementRect, element.titleText, element.style); } subElementRect.x += subElementRect.width + subElementSpacing; } if (element.useInput) { subElementRect.width = element.inputSize; if (subElementRect.width == 0) { subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); } element.inputText = GUI.TextField(subElementRect, element.inputText); subElementRect.x += subElementRect.width + subElementSpacing; } for (int i = 0; i < element.buttons.Count; i++) { subElementRect.width = element.buttons[i].buttonWidth; if (subElementRect.width == 0) { subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); } if (element.buttons[i].style == null) { if (element.buttons[i].isGUIToggle) { element.buttons[i].style = new GUIStyle(GUI.skin.toggle); } else { element.buttons[i].style = new GUIStyle(GUI.skin.button); } } bool resultTrue = false; if (element.buttons[i].isGUIToggle) { resultTrue = GUI.Toggle(subElementRect, element.buttons[i].toggleState, element.buttons[i].buttonText, element.buttons[i].style); element.buttons[i].toggleState = resultTrue; } else { resultTrue = GUI.Button(subElementRect, element.buttons[i].buttonText, element.buttons[i].style); } if (resultTrue) { if (element.buttons[i].genericFunction != null) { element.buttons[i].genericFunction(); } if (element.buttons[i].buttonSpecificFunction != null) { element.buttons[i].buttonSpecificFunction(element.buttons[i]); } if (element.buttons[i].IDfunctionInt != null) { element.buttons[i].IDfunctionInt(element.buttons[i].buttonIDInt); } if (element.buttons[i].IDfunctionString != null) { element.buttons[i].IDfunctionString(element.buttons[i].buttonIDString); } } subElementRect.x += subElementRect.width + subElementSpacing; } lastElementTop += element.height + lineSpacing; } }
public void CardBought(PopupElement newPopupElement) { this.cards [this.actionSelected].transform.GetChild(1).gameObject.SetActive(false); this.cards [this.actionSelected].transform.GetChild(2).gameObject.SetActive(false); this.actionSelected = 0; }
public override void OnStart(PartModule.StartState state) { base.OnStart(state); if (popupWindowID == 0) { popupWindowID = FSGUIwindowID.getNextID(); //Debug.Log("Assigned window ID: " + popupWindowID); } partTransform = part.FindModelTransform(targetPartObject); buildAngleList(); elementSteerRoll = new PopupElement("Use roll steering", new PopupButton("Yes", "No", 0f, toggleSteerRoll)); elementSteerYaw = new PopupElement("Use yaw steering", new PopupButton("Yes", "No", 0f, toggleSteerYaw)); elementSteerPitch = new PopupElement("Use pitch steering", new PopupButton("Yes", "No", 0f, toggleSteerPitch)); elementSteerPitchType = new PopupElement("Pitch type", new PopupButton("Throttle", "Rotation", 0f, toggleSteerPitchType)); elementSteerPitchType.buttons.Add(new PopupButton("Front", "Rear", 0f, toggleSteerPitchLocation)); elementVTOLSteeringMode = new PopupElement("Mode", new PopupButton("Off", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Single", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Double", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Custom", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.titleSize = 30f; #region in editor if (HighLogic.LoadedSceneIsEditor) { elementInfoText = new PopupElement("Presets set to 0 are excluded."); popup = new FSGUIPopup(part, "FSVTOLrotator", 0, popupWindowID, new Rect(550f, 200f, 325f, 150f), "VTOL presets", elementInfoText); //FSGUIwindowID.VTOLrotator popup.sections[0].elements.Add(new PopupElement("Settings are per engine!")); elementTestAngle = new PopupElement(new PopupButton("Use Preset " + selectedListAngle, 100f, testUseAngle)); popup.sections[0].elements.Add(elementTestAngle); elementTestAngle.buttons.Add(new PopupButton("Next", 40f, testNextAngle)); elementTestAngle.buttons.Add(new PopupButton("Reset", 50f, testReset)); elementStepSize = new PopupElement("Step size", stepAngle.ToString()); elementStepSize.titleSize = 135f; elementStepSize.inputSize = 55f; popup.sections[0].elements.Add(elementStepSize); elementMaxDownAngle = new PopupElement("Max negative rot.,", maxDownAngle.ToString()); elementMaxDownAngle.titleSize = 135f; elementMaxDownAngle.inputSize = 55f; popup.sections[0].elements.Add(elementMaxDownAngle); for (int i = 0; i <= 5; i++) // ------------- hard coded --------------------------- { elementPresets.Add(new PopupElement()); float presetAngle = 0f; if (i < availableAnglesList.Count) { presetAngle = availableAnglesList[i]; } elementPresets[i] = new PopupElement("Preset " + i, presetAngle.ToString()); elementPresets[i].titleSize = 135f; elementPresets[i].inputSize = 55f; popup.sections[0].elements.Add(elementPresets[i]); } popup.sections[0].elements.Add(new PopupElement("--- VTOL steering ---")); popup.sections[0].elements.Add(elementVTOLSteeringMode); popup.sections[0].elements.Add(elementSteerRoll); popup.sections[0].elements.Add(elementSteerYaw); popup.sections[0].elements.Add(elementSteerPitch); popup.sections[0].elements.Add(elementSteerPitchType); updateButtonTexts(); popup.useInFlight = false; popup.useInEditor = true; //popup.useInActionEditor = true; } #endregion #region in flight if (HighLogic.LoadedSceneIsFlight) { atmosphericNerf = part.Modules.OfType<FSpropellerAtmosphericNerf>().FirstOrDefault(); // --- moved the element creation to the top, for use in both editor and flight popup = new FSGUIPopup(part, "FSVTOLrotator", 0, popupWindowID, new Rect(500f, 300f, 250f, 100f), "VTOL steering", elementSteerRoll); //FSGUIwindowID.VTOLrotator popup.sections[0].elements.Add(elementSteerYaw); popup.sections[0].elements.Add(elementSteerPitch); popup.sections[0].elements.Add(elementSteerPitchType); popup.useInFlight = true; popup.useInActionEditor = false; if (VTOLSteeringMode != "Custom") { updateSteeringSetup(VTOLSteeringMode); } else { Events["showPopupEvent"].guiActive = true; } updateButtonTexts(); } #endregion }
public override void OnStart(PartModule.StartState state) { base.OnStart(state); if (popupWindowID == 0) { popupWindowID = FSGUIwindowID.getNextID(); } firstPresetLine = 1; PopupElement element = new PopupElement(new PopupButton("+", 25f, adjustTrimFromButton)); element.buttons.Add(new PopupButton("-", 25f, adjustTrimFromButton)); element.buttons.Add(new PopupButton("Add", 43f, addPresetLine)); element.buttons.Add(new PopupButton("Del", 43f, removePresetLine)); popup = new FSGUIPopup(part, "FStrimAdjustment", moduleID, popupWindowID, new Rect(100f, 200f, 180f, 150f), axis + " Trim Adjustment", element);//FSGUIwindowID.trimAdjustment + moduleID if (HighLogic.LoadedSceneIsEditor) { //popup.showMenu = true; elementShowOnFlightStart = new PopupElement("Show on Launch?", new PopupButton("Y", "N", 30f, toggleShowOnFlightStart)); elementShowOnFlightStart.titleSize = 120f; popup.sections[0].elements.Add(elementShowOnFlightStart); elementShowOnFlightStart.buttons[0].toggle(showOnFlightStart); firstPresetLine = 2; } else { if (HighLogic.LoadedSceneIsFlight && showOnFlightStart) { popup.showMenu = true; } else { popup.showMenu = false; } } popup.useInFlight = false; popup.useInEditor = true; //popup.useInActionEditor = true; addPresetLine(presetTrim0); if (presetTrim1 != 0f) { addPresetLine(presetTrim1); } if (presetTrim2 != 0f) { addPresetLine(presetTrim2); } if (HighLogic.LoadedSceneIsEditor) { popup.windowRect.x = 450f; } Actions["togglePopupAction"].guiName = "Toggle " + axis + " Popup"; Actions["usePreset1Action"].guiName = "Use " + axis + " Preset 1"; Events["togglePopupEvent"].guiName = "Toggle " + axis + " Popup"; Actions["increaseTrimAction"].guiName = axis + " trim + 1 step"; Actions["decreaseTrimAction"].guiName = axis + " trim - 1 step"; Actions["increaseTrimMoreAction"].guiName = "" + axis + " trim +" + MoreTrimActionMultiplier + " steps"; Actions["decreaseTrimMoreAction"].guiName = "" + axis + " trim -" + MoreTrimActionMultiplier + " steps"; }
public void ItemBought(PopupElement newPopupElement) { this.itemSelected = 0; }
public override void OnStart(PartModule.StartState state) { base.OnStart(state); if (popupWindowID == 0) { popupWindowID = FSGUIwindowID.getNextID(); //Debug.Log("Assigned window ID: " + popupWindowID); } partTransform = part.FindModelTransform(targetPartObject); buildAngleList(); elementSteerRoll = new PopupElement("Use roll steering", new PopupButton("Yes", "No", 0f, toggleSteerRoll)); elementSteerYaw = new PopupElement("Use yaw steering", new PopupButton("Yes", "No", 0f, toggleSteerYaw)); elementSteerPitch = new PopupElement("Use pitch steering", new PopupButton("Yes", "No", 0f, toggleSteerPitch)); elementSteerPitchType = new PopupElement("Pitch type", new PopupButton("Throttle", "Rotation", 0f, toggleSteerPitchType)); elementSteerPitchType.buttons.Add(new PopupButton("Front", "Rear", 0f, toggleSteerPitchLocation)); elementVTOLSteeringMode = new PopupElement("Mode", new PopupButton("Off", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Single", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Double", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.buttons.Add(new PopupButton("Custom", 0f, buttonSetVTOLSteering)); elementVTOLSteeringMode.titleSize = 30f; #region in editor if (HighLogic.LoadedSceneIsEditor) { elementInfoText = new PopupElement("Presets set to 0 are excluded."); popup = new FSGUIPopup(part, "FSVTOLrotator", 0, popupWindowID, new Rect(550f, 200f, 325f, 150f), "VTOL presets", elementInfoText); //FSGUIwindowID.VTOLrotator popup.sections[0].elements.Add(new PopupElement("Settings are per engine!")); elementTestAngle = new PopupElement(new PopupButton("Use Preset " + selectedListAngle, 100f, testUseAngle)); popup.sections[0].elements.Add(elementTestAngle); elementTestAngle.buttons.Add(new PopupButton("Next", 40f, testNextAngle)); elementTestAngle.buttons.Add(new PopupButton("Reset", 50f, testReset)); elementStepSize = new PopupElement("Step size", stepAngle.ToString()); elementStepSize.titleSize = 135f; elementStepSize.inputSize = 55f; popup.sections[0].elements.Add(elementStepSize); elementMaxDownAngle = new PopupElement("Max negative rot.,", maxDownAngle.ToString()); elementMaxDownAngle.titleSize = 135f; elementMaxDownAngle.inputSize = 55f; popup.sections[0].elements.Add(elementMaxDownAngle); for (int i = 0; i <= 5; i++) // ------------- hard coded --------------------------- { elementPresets.Add(new PopupElement()); float presetAngle = 0f; if (i < availableAnglesList.Count) { presetAngle = availableAnglesList[i]; } elementPresets[i] = new PopupElement("Preset " + i, presetAngle.ToString()); elementPresets[i].titleSize = 135f; elementPresets[i].inputSize = 55f; popup.sections[0].elements.Add(elementPresets[i]); } popup.sections[0].elements.Add(new PopupElement("--- VTOL steering ---")); popup.sections[0].elements.Add(elementVTOLSteeringMode); popup.sections[0].elements.Add(elementSteerRoll); popup.sections[0].elements.Add(elementSteerYaw); popup.sections[0].elements.Add(elementSteerPitch); popup.sections[0].elements.Add(elementSteerPitchType); updateButtonTexts(); popup.useInFlight = false; popup.useInEditor = true; //popup.useInActionEditor = true; } #endregion #region in flight if (HighLogic.LoadedSceneIsFlight) { atmosphericNerf = part.Modules.OfType <FSpropellerAtmosphericNerf>().FirstOrDefault(); // --- moved the element creation to the top, for use in both editor and flight popup = new FSGUIPopup(part, "FSVTOLrotator", 0, popupWindowID, new Rect(500f, 300f, 250f, 100f), "VTOL steering", elementSteerRoll); //FSGUIwindowID.VTOLrotator popup.sections[0].elements.Add(elementSteerYaw); popup.sections[0].elements.Add(elementSteerPitch); popup.sections[0].elements.Add(elementSteerPitchType); popup.useInFlight = true; popup.useInActionEditor = false; if (VTOLSteeringMode != "Custom") { updateSteeringSetup(VTOLSteeringMode); } else { Events["showPopupEvent"].guiActive = true; } updateButtonTexts(); } #endregion }
private void drawElement(PopupElement element) { if (element.showElement) { if (element.style == null) { element.setStyle(GUI.skin.textArea); //GUI.skin.textArea } int activeElements = 0; if (element.useTitle) activeElements++; if (element.useInput) activeElements++; activeElements += element.buttons.Count; if (activeElements < 1) return; Rect subElementRect = new Rect(marginLeft, marginTop + lastSectionTop + lastElementTop, element.titleSize, element.height); if (element.useTitle) { if (subElementRect.width == 0) subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); if (element.useTextArea) GUI.TextArea(subElementRect, element.titleText, element.style); else GUI.Label(subElementRect, element.titleText, element.style); subElementRect.x += subElementRect.width + subElementSpacing; } if (element.useInput) { subElementRect.width = element.inputSize; if (subElementRect.width == 0) subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); element.inputText = GUI.TextField(subElementRect, element.inputText); subElementRect.x += subElementRect.width + subElementSpacing; } for (int i = 0; i < element.buttons.Count; i++) { subElementRect.width = element.buttons[i].buttonWidth; if (subElementRect.width == 0) subElementRect.width = (elementWidth / activeElements) - (subElementSpacing); if (element.buttons[i].style == null) { if (element.buttons[i].isGUIToggle) element.buttons[i].style = new GUIStyle(GUI.skin.toggle); else element.buttons[i].style = new GUIStyle(GUI.skin.button); } bool resultTrue = false; if (element.buttons[i].isGUIToggle) { resultTrue = GUI.Toggle(subElementRect, element.buttons[i].toggleState, element.buttons[i].buttonText, element.buttons[i].style); element.buttons[i].toggleState = resultTrue; } else { resultTrue = GUI.Button(subElementRect, element.buttons[i].buttonText, element.buttons[i].style); } if (resultTrue) { if (element.buttons[i].genericFunction != null) element.buttons[i].genericFunction(); if (element.buttons[i].buttonSpecificFunction != null) element.buttons[i].buttonSpecificFunction(element.buttons[i]); if (element.buttons[i].IDfunctionInt != null) element.buttons[i].IDfunctionInt(element.buttons[i].buttonIDInt); if (element.buttons[i].IDfunctionString != null) element.buttons[i].IDfunctionString(element.buttons[i].buttonIDString); } subElementRect.x += subElementRect.width + subElementSpacing; } lastElementTop += element.height + lineSpacing; } }
public override void OnStart(PartModule.StartState state) { try { deploymentStateEnum = (DeploymentStates)Enum.Parse(typeof(DeploymentStates), deploymentState); } catch { Debug.Log("FSwheel: Could not set deployment state " + deploymentState); } #region animation anim = part.FindModelAnimators(animationName).FirstOrDefault(); if (anim != null) { hasAnimation = true; anim[animationName].layer = animationLayer; float startAnimTime = 0f; if (deploymentStateEnum == DeploymentStates.Retracted) { startAnimTime = 1f; animSpeed = 1f * customAnimationSpeed; } else { animSpeed = -1f * customAnimationSpeed; } anim[animationName].normalizedTime = startAnimTime; anim[animationName].speed = animSpeed; anim.Play(animationName); } #endregion #region In flight if (HighLogic.LoadedSceneIsFlight) { #region create wheel setup List<WheelCollider> colliderList = new List<WheelCollider>(); List<Transform> wheelMeshList = new List<Transform>(); List<Transform> suspensionList = new List<Transform>(); for (int i = 0; i < numberOfWheels; i++) { string suffix = (i + 1).ToString(); // the names used are e.g. "Wheel", "Wheel2", "Wheel3", to remain compatible with stock wheels if (i == 0) suffix = ""; Transform colliderTransform = part.FindModelTransform(wheelColliderName + suffix); if (colliderTransform != null) { WheelCollider collider = colliderTransform.GetComponent<WheelCollider>(); if (collider != null) { colliderList.Add(collider); Transform wheelMeshTransform = part.FindModelTransform(wheelMeshName + suffix); if (wheelMeshTransform != null) { wheelMeshList.Add(wheelMeshTransform); } else { Debug.Log("FSwheel: missing wheel mesh " + wheelMeshName + suffix); } Transform suspensionTransform = part.FindModelTransform(suspensionParentName + suffix); if (suspensionTransform != null) { suspensionList.Add(suspensionTransform); } else { Debug.Log("FSwheel: missing suspensionParent " + suspensionParentName + suffix); } } } else { Debug.Log("FSwheel: missing wheel collider " + wheelColliderName + suffix); } } wheelList.Create(colliderList, wheelMeshList, suspensionList); if (wheelList != null) { if (!wheelList.enabled) { wheelList.enabled = true; } } // set the motor direction based on the first found wheelColliders orientation //Debug.Log("FSwheel: wheelist count is " + wheelList.wheels.Count); if (wheelList.wheels.Count > 0) { Debug.Log("FSwheel: reversemotorset: " + reverseMotorSet); if (!reverseMotorSet) //run only the first time the craft is loaded { float dot = Vector3.Dot(wheelList.wheels[0].wheelCollider.transform.forward, vessel.ReferenceTransform.up); // up is forward if (dot < 0) // below 0 means the engine is on the left side of the craft { reverseMotor = true; //Debug.Log("FSwheel: Reversing motor, dot: " + dot); } else { reverseMotor = false; //Debug.Log("FSwheel: Motor reversing skipped, dot: " + dot); } if (motorStartsReversed) reverseMotor = !reverseMotor; reverseMotorSet = true; } } if (disableColliderWhenRetracted) { if (deploymentStateEnum == DeploymentStates.Retracted) { wheelList.enabled = false; } } //friction override if (overrideModelFrictionValues) { wheelList.forwardStiffness = forwardsStiffness; wheelList.forwardsAsymptoteSlip = forwardsAsymptoteSlip; wheelList.forwardsAsymptoteValue = forwardsAsymptoteValue; wheelList.forwardsExtremumSlip = forwardsExtremumSlip; wheelList.forwardsExtremumValue = forwardsExtremumValue; wheelList.sidewaysStiffness = sidewaysStiffness; wheelList.sidewaysAsymptoteSlip = sidewaysAsymptoteSlip; wheelList.sidewaysAsymptoteValue = sidewaysAsymptoteValue; wheelList.sidewaysExtremumSlip = sidewaysExtremumSlip; wheelList.sidewaysExtremumValue = sidewaysExtremumValue; wheelList.updateWheelFriction(); } //optionally set collider and spring values if ((suspensionSpring >= 0f && suspensionDamper >= 0f && suspensionTargetPosition >= 0f) || overrideModelSpringValues) { wheelList.updateSpring(suspensionSpring, suspensionDamper, suspensionTargetPosition); } if (wheelColliderRadius >= 0f) wheelList.radius = wheelColliderRadius; else wheelColliderRadius = wheelList.radius; if (wheelColliderMass >= 0f) wheelList.mass = wheelColliderMass; if (wheelColliderSuspensionDistance >= 0f || overrideSuspensionDistance) wheelList.suspensionDistance = wheelColliderSuspensionDistance; else wheelColliderSuspensionDistance = wheelList.suspensionDistance; #endregion #region GUI popup popup = new FSGUIPopup(part, "FSwheel", moduleID, FSGUIwindowID.wheel, new Rect(500f, 300f, 250f, 100f), "Wheel settings", new PopupElement("Suspension Settings:")); popup.useInFlight = true; wheelRadiusElement = new PopupElement("Radius", wheelColliderRadius.ToString()); suspensionDistanceElement = new PopupElement("Distance", wheelColliderSuspensionDistance.ToString()); suspensionSpringElement = new PopupElement("Spring", suspensionSpring.ToString()); suspensionDamperElement = new PopupElement("Damper", suspensionDamper.ToString()); suspensionTargetPositionElement = new PopupElement("Target pos", suspensionTargetPosition.ToString()); popup.sections[0].elements.Add(wheelRadiusElement); popup.sections[0].elements.Add(suspensionDistanceElement); popup.sections[0].elements.Add(suspensionSpringElement); popup.sections[0].elements.Add(suspensionDamperElement); popup.sections[0].elements.Add(suspensionTargetPositionElement); suspensionUpdateElement = new PopupElement(new PopupButton("Update", 0f, popupUpdateSuspension)); popup.sections[0].elements.Add(suspensionUpdateElement); #endregion if (brakeEmissiveObjectName != string.Empty) { brakeEmissiveObject = part.FindModelTransform(brakeEmissiveObjectName); } setBrakeLight(brakesEngaged); #region set up fx if (useCustomParticleFX) { smokeFXtexture = GameDatabase.Instance.GetTexture(smokeFXtextureName, false); if (smokeFXtexture == null) { useCustomParticleFX = false; } else { for (int i = 0; i < wheelList.wheels.Count; i++) { wheelList.wheels[i].smokeFX = new Firespitter.FSparticleFX(wheelList.wheels[i].fxLocation, smokeFXtexture); wheelList.wheels[i].smokeFX.AnimatorColor0 = new Color(1.0f, 1.0f, 1.0f, 0.8f); wheelList.wheels[i].smokeFX.AnimatorColor1 = new Color(1.0f, 1.0f, 1.0f, 0.5f); wheelList.wheels[i].smokeFX.AnimatorColor2 = new Color(1.0f, 1.0f, 1.0f, 0.2f); wheelList.wheels[i].smokeFX.AnimatorColor3 = new Color(1.0f, 1.0f, 1.0f, 0.1f); wheelList.wheels[i].smokeFX.AnimatorColor4 = new Color(1.0f, 1.0f, 1.0f, 0.0f); wheelList.wheels[i].smokeFX.EmitterMinSize = 0.3f; wheelList.wheels[i].smokeFX.EmitterMaxSize = 0.5f; wheelList.wheels[i].smokeFX.EmitterMinEnergy = 0.1f; wheelList.wheels[i].smokeFX.EmitterMaxEnergy = 0.3f; wheelList.wheels[i].smokeFX.EmitterMinEmission = 0f; wheelList.wheels[i].smokeFX.EmitterMaxEmission = 0f; wheelList.wheels[i].smokeFX.AnimatorSizeGrow = 0.1f; wheelList.wheels[i].smokeFX.setupFXValues(); } } } #endregion } #endregion #region GUI element changes Events["RaiseGear"].guiActiveUnfocused = guiActiveUnfocused; Events["RaiseGear"].unfocusedRange = unfocusedRange; Events["LowerGear"].guiActiveUnfocused = guiActiveUnfocused; Events["LowerGear"].unfocusedRange = unfocusedRange; Events["EnableMotorEvent"].guiActive = !motorEnabled; Events["DisableMotorEvent"].guiActive = motorEnabled; Events["EnableMotorEvent"].guiActiveEditor = !motorEnabled; Events["DisableMotorEvent"].guiActiveEditor = motorEnabled; Events["brakesOnEvent"].guiActive = !brakesEngaged; Events["brakesOffEvent"].guiActive = brakesEngaged; Events["brakesOnEvent"].guiActiveEditor = !brakesEngaged; Events["brakesOffEvent"].guiActiveEditor = brakesEngaged; Events["EnableReverseMotorEvent"].guiActive = !reverseMotor; Events["DisableReverseMotorEvent"].guiActive = reverseMotor; Events["EnableReverseMotorEvent"].guiActiveEditor = !reverseMotor; Events["DisableReverseMotorEvent"].guiActiveEditor = reverseMotor; Events["brakesOnEvent"].guiActiveUnfocused = guiActiveUnfocused; Events["brakesOffEvent"].guiActiveUnfocused = guiActiveUnfocused; if (!hasMotor) { //Events["EnableMotorEvent"].guiActive = false; //Events["DisableMotorEvent"].guiActive = false; Events["EnableMotorEvent"].active = false; Events["DisableMotorEvent"].active = false; Events["EnableReverseMotorEvent"].active = false; Events["DisableReverseMotorEvent"].active = false; } if (!hasAnimation) { Events["RaiseGear"].active = false; Events["LowerGear"].active = false; } if (debugMode) { Events["increaseFrictionEvent"].guiActive = true; Events["decreaseFrictionEvent"].guiActive = true; Events["suspensionGUIEvent"].guiActive = true; } if (brakesLockedOn) { Events["brakesOnEvent"].guiActive = false; Events["brakesOffEvent"].guiActive = false; Events["brakesOnEvent"].guiActiveUnfocused = false; Events["brakesOffEvent"].guiActiveUnfocused = false; } #endregion }