public override SpawnerOutput CreateScriptedObject(Type type) { SpawnerOutput inst = base.CreateScriptedObject(type); inst.script.transform.SetParent(t.transform); return(inst); }
public override SpawnerOutput ReturnCustomUI(int variable, RuntimeParameters rp) { int p = GetVariableId("Point"); if (p == variable) { SpawnerOutput pField = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)); Dropdown dW = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Dropdown>(pField); List <Dropdown.OptionData> dOd = new List <Dropdown.OptionData>(); RuntimeParameters <int> rpI = rp as RuntimeParameters <int>; dOd.Add(new Dropdown.OptionData("X")); dOd.Add(new Dropdown.OptionData("Y")); dW.AddOptions(dOd); dW.value = rpI.v; dW.onValueChanged.AddListener((id) => { rpI.v = id; }); return(pField); } return(base.ReturnCustomUI(variable, rp)); }
void Start() { // Applies pending data that was recieved while loading. Debug.Log("Updating " + pendingData.Count + " messages while loading."); for (int i = 0; i < pendingData.Count; i++) { (NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.UPDATE_ABILITY_DATA] as UpdateAbilityDataEncoder).ParseMessage(pendingData[i]); } pendingData.Clear(); playerLoadedInLobby = true; // Creates global variables for this player. aData[ClientProgram.clientId].abilties[""].InputCallback(0); // Creates player main character. string priCharacterId = aData[ClientProgram.clientId].abilityManifest[(int)AbilityManifest.PRIMARY_CHARACTER]; aData[ClientProgram.clientId].abilties[priCharacterId].InputCallback(0); abilities = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout)); (abilities.script as LinearLayout).o = LinearLayout.Orientation.X; abilities.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f,0.1f)); AssignInputKeys(); }
void GenerateMenuElements() { SpawnerOutput topText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(topText).text = "Abilities"; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(topText).color = Color.white; topText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.5f, 0.9f)); commandText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(commandText).text = ""; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(commandText).color = Color.white; commandText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.5f, 0.75f)); SpawnerOutput addAbility = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(addAbility).onClick.AddListener(() => { CreateAbility(); }); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(addAbility, "Text").text = "Create Ability"; addAbility.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.15f, 0.1f)); SpawnerOutput setNewPrimary = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(setNewPrimary).onClick.AddListener(() => { ChangeButtonMode(AbilityButtonMode.CHANGE_PRIMARY_CHARACTER); }); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(setNewPrimary, "Text").text = "Set new primary"; setNewPrimary.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.9f, 0.8f)); lL = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout)); lL.script.transform.position = UIDrawer.UINormalisedPosition(new Vector2(0.1f, 0.75f)); }
void GenerateAbilityElement(string index) { SpawnerOutput abilityButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(abilityButton, "Text").text = abilityInfo[index].n; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(abilityButton).onClick.AddListener(() => { selectedAbility = index; switch (currMode) { case AbilityButtonMode.CHANGE_PRIMARY_CHARACTER: if (!abilityManifest.ContainsKey((int)AbilityManifest.PRIMARY_CHARACTER)) { abilityManifest.Add((int)AbilityManifest.PRIMARY_CHARACTER, index); } else { abilityManifest[(int)AbilityManifest.PRIMARY_CHARACTER] = index; } SaveAbilityManifest(); break; case AbilityButtonMode.DEFAULT: SceneTransitionData.LoadScene("AbilityMaker"); break; } ChangeButtonMode(AbilityButtonMode.DEFAULT); }); //UIDrawer.ChangeUISize(abilityButton, new Vector2(200, 30)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(lL).Add(abilityButton.script.transform as RectTransform); }
// Use this for initialization void Start() { AbilitiesManager.playerLoadedInLobby = false; lobbyInst = this; cDT = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.CUSTOM_DATA_TRASMIT] as PlayerCustomDataTrasmitter; iDT = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.IMAGE_DATA_TRANSMIT] as ImageDependenciesTransfer; mE = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.MANIFEST] as ManifestEncoder; ResetGameplayNetworkHelpers(); lobbyText = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper)); lobbyText.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.9f)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(lobbyText).text = "Lobby"; progressOfFiles = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper)); progressOfFiles.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.5f)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(progressOfFiles).verticalOverflow = VerticalWrapMode.Overflow; startGame = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); startGame.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.1f)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(startGame, "Text").text = "Start Game"; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(startGame).onClick.AddListener(() => { ServerChannel sC = NetworkMessageEncoder.encoders[(int)NetworkEncoderTypes.SERVER_CHANNEL] as ServerChannel; sC.CommunicateServerSide(ServerSideMethods.START_GAME); }); }
SpawnerOutput CreatePixel() { SpawnerOutput inst = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(Image)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(inst).rectTransform.sizeDelta = lw; inst.script.transform.parent = transform; return(inst); }
void CreateNewPixel() { if (imageData[Mathf.RoundToInt(mPos.x / scaleFactor), Mathf.RoundToInt(mPos.y / scaleFactor)] == null) { imageData[Mathf.RoundToInt(mPos.x / scaleFactor), Mathf.RoundToInt(mPos.y / scaleFactor)] = pointer; pointer = CreatePixel(); } }
public T GetTypeInElement <T>(SpawnerOutput t, params string[] cN) { UIWrapperBase target = t.script as UIWrapperBase; if (target != null) { return(InternalRecursiveGetType <T>(target, 0, cN)); } return((T)(object)t.script); }
public static void ChangeUISize(SpawnerOutput t, Vector2 size) { (t.script.transform as RectTransform).sizeDelta = size; UIWrapperBase target = t.script as UIWrapperBase; if (target != null) { for (int i = 0; i < target.scriptsData.Length; i++) { (target.scriptsData[i].script.transform as RectTransform).sizeDelta = size; } } }
public KeyCodeDropdownList(int keycode) { PopulateValues(); dW = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)); ReturnDropdownWrapper().dropdown.AddOptions(inputNames); for (int i = 0; i < inputValues.Length; i++) { if (keycode == inputValues[i]) { ReturnDropdownWrapper().dropdown.value = i; } } }
public AbilityTreeNode CreateNewNodeIfNull(int nodeId) { //Debug.Log(nodeId); if (!nodes[nodeId]) { // Tries to convert type into a singleton to see if it exist. if (LoadedData.singletonList.ContainsKey(subclassTypes[nodeId])) { nodes[nodeId] = LoadedData.singletonList[subclassTypes[nodeId]] as AbilityTreeNode; } if (nodes[nodeId] == null) { SpawnerOutput sOInst = LoadedData.GetSingleton <Spawner>().CreateScriptedObject(subclassTypes[nodeId]); nodes[nodeId] = sOInst.script as AbilityTreeNode; nodes[nodeId].SetSourceObject(sOInst); // Changes its name nodes[nodeId].name = castingPlayer.ToString() + '/' + centralId.ToString() + '/' + nodeId.ToString(); // Adds it to root nodes[nodeId].transform.SetParent(abilityNodeRoot); } AbilityTreeNode inst = nodes[nodeId]; inst.SetNodeThreadId(-1); inst.SetNodeId(nodeId); inst.SetCentralId(castingPlayer, centralId); IOnNodeInitialised oNNInst = inst as IOnNodeInitialised; if (oNNInst != null) { oNNInst.OnNodeInitialised(); } return(inst); } return(nodes[nodeId]); }
public void AssignInputKeys() { if (aData.ContainsKey(ClientProgram.clientId)) { foreach (var ability in aData[ClientProgram.clientId].abilties) { if (!aData[ClientProgram.clientId].abilityManifest.ContainsValue(ability.Key)) { int keyAssigned = aData[ClientProgram.clientId].abilties[ability.Key].abilityInfo.kC; LoadedData.GetSingleton <PlayerInput>().AddNewInput(aData[ClientProgram.clientId].abilties[ability.Key],0,(KeyCode)keyAssigned,0,true); SpawnerOutput abilityButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(abilityButton,"Text").text = aData[ClientProgram.clientId].abilties[ability.Key].abilityInfo.n; (abilities.script as LinearLayout).Add(abilityButton.script.transform as RectTransform); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(abilityButton).onClick.AddListener(() => { aData[ClientProgram.clientId].abilties[ability.Key].InputCallback(0); }); } } } }
void Start() { mPos = new Vector2(); rcs = 16; dimensions = 450; PNGDimensions = 1024; CalibrateEditor(); SpawnerOutput sO = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(sO).onClick.AddListener(SavePNG); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(sO, "Text").text = "Save Art"; SpawnerOutput nO = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(nO).onValueChanged.AddListener((s) => { name = s; }); sO.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.9f)); nO.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.8f)); GeneratePixels(); pointer = CreatePixel(); /*colors = new Color[1000]; * for (int i = 0; i < colors.Length; i++) * if (i < 500) * colors[i] = Color.red; * else * colors[i] = Color.black; * * colorTest = new Texture2D(100, 10); * colorTest.SetPixels(colors); * * File.WriteAllBytes(Application.dataPath + "/../test6.png", colorTest.EncodeToPNG());*/ }
void CreateLines(Transform[] points, int id) { // Creates the graphical strings. SpawnerOutput lGraphic = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(lGraphic, "Image").rectTransform.pivot = new Vector2(0.5f, 0); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(lGraphic, "Text").text = ""; // Adds event for changing of button colors LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(lGraphic).onClick.AddListener(() => { switch (mMode) { case MouseMode.EDIT_CONN: int[] linkData = abilityData.linkAddresses.l[id]; if (!LoadedData.GetVariableType(abilityData.subclasses.l[linkData[0]].classType, linkData[1], VariableTypes.PERMENANT_TYPE)) { linkData[4] = (int)lMode; UpdateLineColor(id); mMode = MouseMode.NONE; } break; case MouseMode.REMOVE_CONN: RemoveLine(id); mMode = MouseMode.NONE; break; } }); LineData line = new LineData(points[0], points[1], lGraphic); lineData.ModifyElementAt(id, line); UpdateLineColor(id); UpdateLines(id); }
SpawnerOutput CreateVariableButtons(ActionType aT, int[] id) { SpawnerOutput linkageButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(linkageButton, "Text").text = ""; UIDrawer.ChangeUISize(linkageButton, new Vector2(20, 20)); switch (aT) { case ActionType.RECIEVE: LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(linkageButton).onClick.AddListener(() => { CreateLinkage(id); }); break; case ActionType.SEND: LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(linkageButton).onClick.AddListener(() => { prevPath = id; }); break; } return(linkageButton); }
void GeneratePixels() { byte[] fileData; string path; Texture2D tex; colorData = new Color[100, 10]; path = Path.Combine(new string[] { LoadedData.gameDataPath, "Datafiles", "2", "ImageAssets", "Bullet" }); path += ".png"; if (File.Exists(path)) { fileData = File.ReadAllBytes(path); tex = new Texture2D(1, 1); tex.LoadImage(fileData); //ImageConversion.LoadImage(tex, fileData); //display.sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2()); colorData = ImageFileReader.ReadImageFile(tex.GetPixels()); } for (int i = 0; i < colorData.GetLength(0); i++) { for (int j = 0; j < colorData.GetLength(1); j++) { if (colorData[i, j].a > 0) { SpawnerOutput inst = CreatePixel(); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(inst).color = colorData[i, j]; inst.script.transform.localPosition = new Vector2(scaleFactor * i, scaleFactor * j) + pixelOffset; imageData[i, j] = inst; } } } }
public override SpawnerOutput ReturnCustomUI(int variable, RuntimeParameters rp) { int aN = GetVariableId("Ability Name"); if (variable == aN) { SpawnerOutput aNField = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)); Dropdown dW = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Dropdown>(aNField); List <Dropdown.OptionData> dOd = new List <Dropdown.OptionData>(); RuntimeParameters <string> rpS = rp as RuntimeParameters <string>; int selected = 0; foreach (var kPV in AbilityPageScript.abilityInfo) { dOd.Add(new Dropdown.OptionData(kPV.Value.n)); if (kPV.Key == rpS.v) { selected = dOd.Count - 1; } } dW.AddOptions(dOd); dW.value = selected; dW.onValueChanged.AddListener((id) => { string[] dirNames = AbilityPageScript.abilityInfo.Keys.ToArray(); rpS.v = dirNames[id]; }); return(aNField); } return(base.ReturnCustomUI(variable, rp)); }
public override SpawnerOutput ReturnCustomUI(int variable, RuntimeParameters rp) { int o = GetVariableId("Sprite Name"); if (o == variable) { SpawnerOutput oField = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)); Dropdown dW = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Dropdown>(oField); List <Dropdown.OptionData> dOd = new List <Dropdown.OptionData>(); RuntimeParameters <string> rpI = rp as RuntimeParameters <string>; int ddId = 0; var imagePaths = new DirectoryInfo(Path.Combine(LoadedData.gameDataPath, "UsrCreatedArt")).GetFiles().Where(x => x.Extension != ".meta"); foreach (FileInfo fI in imagePaths) { if (fI.Name == rpI.v) { ddId = dOd.Count; } dOd.Add(new Dropdown.OptionData(fI.Name)); //Od.Add(new Dropdown.OptionData("Actual Position")); } dW.AddOptions(dOd); dW.value = ddId; dW.onValueChanged.AddListener((id) => { rpI.v = dOd[id].text; }); return(oField); } return(base.ReturnCustomUI(variable, rp)); }
public LineData(Transform start, Transform end, SpawnerOutput line) { s = start; e = end; l = line; }
void Start() { string cData = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 0); string wData = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 2); if (cData != "") { abilityData = new UIAbilityData(LoadedData.GetSingleton <JSONFileConvertor>().ConvertToData(JsonConvert.DeserializeObject <StandardJSONFileFormat[]>(cData)), JsonConvert.DeserializeObject <float[][]>(wData)); } else { abilityData = new UIAbilityData(); } abilityWindows = new AutoPopulationList <EditableWindow>(); lineData = new AutoPopulationList <LineData>(); SpawnUIFromData(); mainClassSelection = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout)); SpawnerOutput name = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper)); name.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.9f)); InputField castedName = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(name); string data = FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericLoadTrigger(new string[] { AbilityPageScript.selectedAbility }, 1); abilityDescription = JsonConvert.DeserializeObject <AbilityInfo>(data); castedName.text = abilityDescription.n; castedName.onValueChanged.AddListener((s) => { abilityDescription.n = s; }); SpawnerOutput[] buttons = new SpawnerOutput[LoadedData.loadedNodeInstance.Count]; foreach (KeyValuePair <Type, AbilityTreeNode> entry in LoadedData.loadedNodeInstance) { SpawnerOutput button = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); Button butInst = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(button); // Need another way to get elements within spawner output... LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(button, "Text").text = entry.Key.Name; butInst.onClick.AddListener(() => { selectedType = entry.Key; windowSpawner.script.gameObject.SetActive(true); mMode = MouseMode.CREATE_NODE; }); (mainClassSelection.script as LinearLayout).Add(butInst.transform as RectTransform); } classSelectionScrollRect = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ScrollRectWrapper)); (classSelectionScrollRect.script as ScrollRectWrapper).ChangeScrollRectSize(new Vector2(100, 600)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <UIMule>(classSelectionScrollRect, "Content").GetRectTransform().sizeDelta = (mainClassSelection.script.transform as RectTransform).sizeDelta; classSelectionScrollRect.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.6f)); mainClassSelection.script.transform.SetParent(LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <UIMule>(classSelectionScrollRect, "Content").transform); mainClassSelection.script.transform.localPosition = new Vector2(-(mainClassSelection.script.transform as RectTransform).sizeDelta.x / 2, 0); windowSpawner = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(Image)); windowSpawner.script.gameObject.SetActive(false); SpawnerOutput optLL = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout)); SpawnerOutput normConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(normConnButt, "Text").text = "Normal Conection"; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(normConnButt, "Image").color = Color.green; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(normConnButt).onClick.AddListener(() => { mMode = MouseMode.EDIT_CONN; lMode = LinkMode.NORMAL; }); SpawnerOutput sigConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(sigConnButt, "Text").text = "Signal Conection"; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(sigConnButt, "Image").color = Color.red; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(sigConnButt).onClick.AddListener(() => { mMode = MouseMode.EDIT_CONN; lMode = LinkMode.SIGNAL; }); SpawnerOutput rmConnButt = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(rmConnButt,"Text").text = "Remove Conection"; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(rmConnButt).onClick.AddListener(() => { mMode = MouseMode.REMOVE_CONN; }); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(normConnButt.script.transform as RectTransform); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(sigConnButt.script.transform as RectTransform); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(optLL).Add(rmConnButt.script.transform as RectTransform); optLL.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.9f,0.9f)); SpawnerOutput saveButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Button>(saveButton).onClick.AddListener(() => { int[] aEle = abilityData.subclasses.ReturnActiveElementIndex(); AbilityDataSubclass[] cAD = abilityData.RelinkSubclass(); string[] imgDependencies = AbilityDataSubclass.GetImageDependencies(cAD); // Gets all window locations. float[][] windowLocations = new float[cAD.Length][]; for (int i = 0; i < windowLocations.Length; i++) { windowLocations[i] = new float[2]; windowLocations[i][0] = abilityWindows.l[aEle[i]].transform.position.x; windowLocations[i][1] = abilityWindows.l[aEle[i]].transform.position.y; } FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility },0,JsonConvert.SerializeObject(LoadedData.GetSingleton <JSONFileConvertor>().ConvertToStandard(cAD))); FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 1, JsonConvert.SerializeObject(abilityDescription)); FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 2, JsonConvert.SerializeObject(windowLocations)); FileSaver.sFT[FileSaverTypes.PLAYER_GENERATED_DATA].GenericSaveTrigger(new string[] { AbilityPageScript.selectedAbility }, 3, JsonConvert.SerializeObject(imgDependencies)); }); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(saveButton, "Text").text = "Save JSON"; saveButton.script.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.5f, 0.1f)); // Creates dropdown for input. kcDdL = new KeyCodeDropdownList(abilityDescription.kC); kcDdL.ReturnDropdownWrapper().transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.75f, 0.9f)); kcDdL.ReturnDropdownWrapper().dropdown.onValueChanged.AddListener((v) => { abilityDescription.kC = KeyCodeDropdownList.inputValues[v]; }); // Creates dropdown for startnode. //DropdownWrapper sNDW = LoadedData.GetSingleton<UIDrawer>().CreateScriptedObject(typeof(DropdownWrapper)).script as DropdownWrapper; ButtonWrapper addOptionsButton = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)).script as ButtonWrapper; addOptionsButton.button.onClick.AddListener(() => CreateWindowForAdditionalOptions()); addOptionsButton.text.text = "Additional Options"; addOptionsButton.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.2f)); ButtonWrapper exitBlueprintMaker = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ButtonWrapper)).script as ButtonWrapper; exitBlueprintMaker.button.onClick.AddListener(() => SceneTransitionData.LoadScene("AbilityPage")); exitBlueprintMaker.text.text = "Exit"; exitBlueprintMaker.transform.position = UIDrawer.UINormalisedPosition(new Vector3(0.1f, 0.1f)); }
SpawnerOutput[] CreateVariableField(int id,int varId) { SpawnerOutput elementName = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(TextWrapper)); SpawnerOutput element = LoadedData.loadedNodeInstance[abilityData.subclasses.l[id].classType].ReturnCustomUI(varId,abilityData.subclasses.l[id].var[varId].field); if (element == null) { element = ReturnElementField(id,varId); } Text eName = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Text>(elementName); eName.text = abilityData.subclasses.l[id].var[varId].field.n; eName.color = Color.white; if (element != null) { return new SpawnerOutput[] { elementName,element } } ; return(new SpawnerOutput[] { elementName }); } SpawnerOutput ReturnElementField(int id,int varId) { SpawnerOutput element = null; RuntimeParameters variable = abilityData.subclasses.l[id].var[varId].field; if (variable.t == typeof(string)) { element = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).text = (variable as RuntimeParameters <string>).v; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).onValueChanged.AddListener((s) => { (abilityData.subclasses.l[id].var[varId].field as RuntimeParameters <string>).v = s; }); } if (variable.t == typeof(int)) { element = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).text = (variable as RuntimeParameters <int>).v.ToString(); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).onValueChanged.AddListener((s) => { int i = 0; if (int.TryParse(s,out i)) { (abilityData.subclasses.l[id].var[varId].field as RuntimeParameters <int>).v = i; } }); } if (variable.t == typeof(float)) { element = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(InputFieldWrapper)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).text = (variable as RuntimeParameters <float>).v.ToString(); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <InputField>(element).onValueChanged.AddListener((s) => { float f = 0; if (float.TryParse(s,out f)) { (abilityData.subclasses.l[id].var[varId].field as RuntimeParameters <float>).v = f; } }); } if (variable.t == typeof(bool)) { element = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(ToggleWrapper)); Toggle t = LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Toggle>(element); RuntimeParameters <bool> b = variable as RuntimeParameters <bool>; t.isOn = b.v; t.onValueChanged.AddListener((value) => { b.v = value; }); } return(element); }
public void CreateWindow(int id, Vector3 location) { EditableWindow editWindow = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(EditableWindow)).script as EditableWindow; editWindow.link = this; //Runs deletion delegate. Button del = editWindow.deleteButton.button; del.onClick.AddListener(() => { //Handles UI deletion. editWindow.gameObject.SetActive(false); for (int i = editWindow.linesRelated.Count - 1; i >= 0; i--) { //lineData.l[editWindow.linesRelated[i]].line.gameObject.SetActive(false); //abilityData.linkAddresses.Remove(editWindow.linesRelated[i]); RemoveLine(editWindow.linesRelated[i]); } abilityData.subclasses.Remove(id); }); editWindow.transform.position = location; abilityWindows.ModifyElementAt(id, editWindow); //Initialises variable linear layouts. editWindow.variables = new SpawnerOutput[abilityData.subclasses.l[id].var.Length]; Vector2 varGraphicsDimensions = new Vector2(0, 0); for (int i = 0; i < abilityData.subclasses.l[id].var.Length; i++) { if (LoadedData.GetVariableType(abilityData.subclasses.l[id].classType, i, VariableTypes.HIDDEN)) { continue; } SpawnerOutput[] var = CreateVariableField(id, i); SpawnerOutput get = CreateVariableButtons(ActionType.RECIEVE, new int[] { id, i }); SpawnerOutput set = CreateVariableButtons(ActionType.SEND, new int[] { id, i }); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(get, "Image").color = Color.red; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <Image>(set, "Image").color = Color.green; SpawnerOutput align = LoadedData.GetSingleton <UIDrawer>().CreateScriptedObject(typeof(LinearLayout)); LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(align).o = LinearLayout.Orientation.X; LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(align).Add(get.script.transform as RectTransform); for (int j = 0; j < var.Length; j++) { LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(align).Add(var[j].script.transform as RectTransform); } LoadedData.GetSingleton <UIDrawer>().GetTypeInElement <LinearLayout>(align).Add(set.script.transform as RectTransform); //(align.script.transform as RectTransform).sizeDelta = (align.script.transform as RectTransform).sizeDelta; editWindow.lL.Add(align.script.transform as RectTransform); editWindow.variables[i] = align; varGraphicsDimensions.y += (align.script.transform as RectTransform).sizeDelta.y; if ((align.script.transform as RectTransform).sizeDelta.x > varGraphicsDimensions.x) { varGraphicsDimensions.x = (align.script.transform as RectTransform).sizeDelta.x; } } editWindow.ChangeWindowsContentSize(varGraphicsDimensions); editWindow.windowsText.text = abilityData.subclasses.l[id].classType.Name; }
public void SetSourceObject(SpawnerOutput srcObject) { sourceObject = srcObject; }