private float DrawInventory(AdventureDataControl adventureData, Matrix4x4 matrix, Vector2 corner, Vector2 backgroundSize, float scale, float progress) { corner = matrix.MultiplyPoint(corner); backgroundSize = matrix.MultiplyVector(backgroundSize); var rectOpen = new Rect(corner, new Vector2(backgroundSize.x, scale * 100f * 1)); var rect = new Rect(corner, new Vector2(backgroundSize.x, scale * 100 * progress)); if (rectOpen.height < 0) { rectOpen.y += rectOpen.height; rectOpen.height = -rectOpen.height; } Handles.DrawSolidRectangleWithOutline(rect, new Color(0.1f, 0.1f, 0.1f, 0.2f), new Color(0.1f, 0.1f, 0.1f, 0.8f)); if (Event.current.type == EventType.Repaint) { if (rectOpen.Contains(Event.current.mousePosition)) { growing = true; this.scale = scale; } } return(Mathf.Clamp01(progress)); }
private static void EditComentaries(AdventureDataControl adventureData) { // Adventure commentaries EditorGUILayout.LabelField(TC.get("MenuAdventure.Commentaries"), EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); var newCommentaries = EditorGUILayout.Toggle(TC.get("MenuAdventure.CommentariesLabel"), adventureData.isCommentaries(), GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { adventureData.setCommentaries(newCommentaries); } }
private static void EditKeepShowing(AdventureDataControl adventureData) { // Keep showing texts or change after time EditorGUILayout.LabelField(TC.get("MenuAdventure.KeepShowing"), EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); var newKeep = EditorGUILayout.Toggle(TC.get("MenuAdventure.KeepText"), adventureData.isKeepShowing(), GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { adventureData.setKeepShowing(newKeep); } }
private static void EditKeyboardNavigation(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("MenuAdventure.KeyboardNavigationEnabled"), EditorStyles.boldLabel); using (new EditorGUI.DisabledScope(true)) // TODO add navigation control by keyboard { EditorGUI.BeginChangeCheck(); var newKeyboardNavigation = EditorGUILayout.Toggle(TC.get("MenuAdventure.KeyboardNavigationEnabled.Checkbox"), adventureData.isKeyboardNavigationEnabled(), GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck()) { adventureData.setKeyboardNavigation(newKeyboardNavigation); } } }
private static void EditDragBehaviour(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("DragBehaviour.Explanation"), EditorStyles.boldLabel); int[] dragValues = { (int)DescriptorData.DragBehaviour.CONSIDER_NON_TARGETS, (int)DescriptorData.DragBehaviour.IGNORE_NON_TARGETS }; string[] dragTexts = { TC.get("DragBehaviour.ConsiderNonTargets"), TC.get("DragBehaviour.IgnoreNonTrargets") }; using (new EditorGUI.DisabledScope(true)) // TODO add drag values { EditorGUI.BeginChangeCheck(); var newDrag = EditorGUILayout.IntPopup((int)adventureData.getDragBehaviour(), dragTexts, dragValues); if (EditorGUI.EndChangeCheck()) { adventureData.setDragBehaviour((DescriptorData.DragBehaviour)newDrag); } } }
private static void EditPerspective(AdventureDataControl adventureData) { // Perspectives EditorGUILayout.LabelField(TC.get("Perspective.Explanation"), EditorStyles.boldLabel); int[] perspectiveValues = { (int)DescriptorData.Perspective.REGULAR, (int)DescriptorData.Perspective.ISOMETRIC }; string[] perspectiveTexts = { TC.get("Perspective.Regular"), TC.get("Perspective.Isometric") }; using (new EditorGUI.DisabledScope(true)) // TODO add perspectives { EditorGUI.BeginChangeCheck(); var newPerspective = EditorGUILayout.IntPopup((int)adventureData.getPerspective(), perspectiveTexts, perspectiveValues); if (EditorGUI.EndChangeCheck()) { adventureData.setPerspective((DescriptorData.Perspective)newPerspective); } } }
private static void EditDefaultClickAction(AdventureDataControl adventureData) { // Default click action EditorGUILayout.LabelField(TC.get("DefaultClickAction.Explanation"), EditorStyles.boldLabel); int[] clickValues = { (int)DescriptorData.DefaultClickAction.SHOW_DETAILS, (int)DescriptorData.DefaultClickAction.SHOW_ACTIONS }; string[] clickTexts = { TC.get("DefaultClickAction.ShowDetails"), TC.get("DefaultClickAction.ShowActions") }; using (new EditorGUI.DisabledScope(true)) // TODO add clickAction control { EditorGUI.BeginChangeCheck(); var newDefaultClickAction = EditorGUILayout.IntPopup((int)adventureData.getDefaultClickAction(), clickTexts, clickValues); if (EditorGUI.EndChangeCheck()) { adventureData.setDefaultClickAction((DescriptorData.DefaultClickAction)newDefaultClickAction); } } }
private static void EditSaveMode(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("MenuAdventure.SaveMode"), EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); var newAutoSave = EditorGUILayout.Toggle(TC.get("MenuAdventure.AutoSave.Checkbox"), adventureData.isAutoSave()); if (EditorGUI.EndChangeCheck()) { adventureData.setAutoSave(newAutoSave); } EditorGUI.BeginChangeCheck(); var newSaveOnSuspend = EditorGUILayout.Toggle(TC.get("MenuAdventure.SaveOnSuspend.Checkbox"), adventureData.isSaveOnSuspend()); if (EditorGUI.EndChangeCheck()) { adventureData.setSaveOnSuspend(newSaveOnSuspend); } }
private static void EditData(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("Adventure.Title"), EditorStyles.boldLabel); EditorGUILayout.LabelField(TC.get("Adventure.AdventureTitle")); EditorGUI.BeginChangeCheck(); var newTitle = EditorGUILayout.TextField(adventureData.getTitle()); if (EditorGUI.EndChangeCheck()) { adventureData.setTitle(newTitle); } EditorGUILayout.LabelField(TC.get("Adventure.AdventureDescription")); EditorGUI.BeginChangeCheck(); var newDescription = EditorGUILayout.TextArea(adventureData.getDescription(), GUILayout.Height(80)); if (EditorGUI.EndChangeCheck()) { adventureData.setDescription(newDescription); } }
private void DrawIconInventory(AdventureDataControl adventureData, Matrix4x4 matrix) { if (icon != null) { var scale = adventureData.getInventoryScale(); var pos = matrix.MultiplyPoint3x4(adventureData.getInventoryCoords()); var textureSize = matrix.MultiplyVector(new Vector2(icon.width, icon.height)); var inventorySize = textureSize * scale; var inventoryCorner = pos - new Vector3(inventorySize.x / 2f, inventorySize.y); var inventoryRect = new Rect(inventoryCorner, inventorySize); GUI.DrawTexture(inventoryRect, icon); EditorGUI.BeginChangeCheck(); var inventoryId = GUIUtility.GetControlID("SizeId".GetHashCode(), FocusType.Passive, inventoryRect); var newRect = HandleUtil.HandleFixedRatioRect(inventoryId, inventoryRect, icon.width / (float)icon.height, 10f, (polygon, over, active) => HandleUtil.DrawPolyLine(polygon, true, Color.red, over || active ? 4f : 2f), (point, over, active) => HandleUtil.DrawPoint(point, 4.5f, Color.blue, over || active ? 2f : 1f, over || active ? Color.red : Color.black)); if (EditorGUI.EndChangeCheck()) { var newScale = newRect.width / (float)textureSize.x; var newCoords = InverseMultiplyPoint(matrix, newRect.center + new Vector2(0, newRect.height / 2f)); adventureData.setInventoryCoords(newCoords); adventureData.setInventoryScale(newScale); } EditorGUI.BeginChangeCheck(); var inventoryMovementId = GUIUtility.GetControlID("MovementId".GetHashCode(), FocusType.Passive, inventoryRect); newRect = HandleUtil.HandleRectMovement(inventoryMovementId, newRect); if (EditorGUI.EndChangeCheck()) { var newCoords = InverseMultiplyPoint(matrix, newRect.center + new Vector2(0, newRect.height / 2f)); adventureData.setInventoryCoords(newCoords); } } }
private static void EditMode(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("Adventure.PlayerMode"), EditorStyles.boldLabel); EditorGUILayout.LabelField(TC.get("Adventure.CurrentPlayerMode")); string modeName; string modeDescription; switch (adventureData.getPlayerMode()) { case DescriptorData.MODE_PLAYER_3RDPERSON: modeName = TC.get("Adventure.ModePlayerTransparent.Name"); modeDescription = TC.get("Adventure.ModePlayerTransparent.Description"); break; default: modeName = TC.get("Adventure.ModePlayerVisible.Name"); modeDescription = TC.get("Adventure.ModePlayerVisible.Description"); break; } GUILayout.Box(modeName, GUILayout.ExpandWidth(true)); GUILayout.Box(modeDescription); }
private static void EditSaveMode(AdventureDataControl adventureData, Rect rect) { bool newValue; using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true))) { EditorGUIUtility.labelWidth = rect.width - 30; EditorGUILayout.LabelField(TC.get("MenuAdventure.SaveMode"), EditorStyles.boldLabel); EditorGUILayout.HelpBox(TC.get("MenuAdventure.SaveMode.Info"), MessageType.Warning); if (CheckedField("MenuAdventure.ShowSaveLoad", adventureData.isShowSaveLoad(), out newValue)) { adventureData.setShowSaveLoad(newValue); } if (CheckedField("MenuAdventure.ShowReset", adventureData.isShowReset(), out newValue)) { adventureData.setShowReset(newValue); } if (CheckedField("MenuAdventure.AutoSave", adventureData.isAutoSave(), out newValue)) { adventureData.setAutoSave(newValue); } if (CheckedField("MenuAdventure.SaveOnSuspend", adventureData.isSaveOnSuspend(), out newValue)) { adventureData.setSaveOnSuspend(newValue); } if (CheckedField("MenuAdventure.RestoreAfterOpen", adventureData.isRestoreAfterOpen(), out newValue)) { adventureData.setRestoreAfterOpen(newValue); } } }
public TrackerConfigDataControl(AdventureDataControl adventureData) { this.trackerConfig = adventureData.getAdventureData().getTrackerConfig(); }
private static void ShowVersionNumber(AdventureDataControl adventureData) { EditorGUILayout.LabelField(TC.get("VersionNumber"), EditorStyles.boldLabel); GUILayout.Box(adventureData.getVersionNumber(), GUILayout.ExpandWidth(true)); }
/** * Writes the daventure data into the given file. * * @param folderName * Folder where to write the data * @param adventureData * Adventure data to write in the file * @param valid * True if the adventure is valid (can be executed in the * engine), false otherwise * @return True if the operation was succesfully completed, false otherwise */ public static bool writeData(string folderName, AdventureDataControl adventureData, bool valid) { bool dataSaved = false; // Create the necessary elements for building the DOM doc = new XmlDocument(); // Delete the previous XML files in the root of the project dir //DirectoryInfo projectFolder = new DirectoryInfo(folderName); //if (projectFolder.Exists) //{ // foreach (FileInfo file in projectFolder.GetFiles()) // { // file.Delete(); // } // foreach (DirectoryInfo dir in projectFolder.GetDirectories()) // { // dir.Delete(true); // } //} // Add the special asset files // TODO AssetsController.addSpecialAssets(); /** ******* START WRITING THE DESCRIPTOR ********* */ // Pick the main node for the descriptor XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "no"); //XmlDocumentType typeDescriptor = doc.CreateDocumentType("game-descriptor", "SYSTEM", "descriptor.dtd", null); doc.AppendChild(declaration); //doc.AppendChild(typeDescriptor); if (!valid) { DOMWriterUtility.DOMWrite(doc, adventureData, new DescriptorDOMWriter.InvalidAdventureDataControlParam()); } else { DOMWriterUtility.DOMWrite(doc, adventureData); } doc.Save(folderName + "/descriptor.xml"); /** ******** END WRITING THE DESCRIPTOR ********** */ /** ******* START WRITING THE CHAPTERS ********* */ // Write every chapter //XmlDocumentType typeChapter; int chapterIndex = 1; foreach (Chapter chapter in adventureData.getChapters()) { doc = new XmlDocument(); declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "no"); //typeChapter = doc.CreateDocumentType("eAdventure", "SYSTEM", "eadventure.dtd", null); doc.AppendChild(declaration); //doc.AppendChild(typeChapter); DOMWriterUtility.DOMWrite(doc, chapter); doc.Save(folderName + "/chapter" + chapterIndex++ + ".xml"); } /** ******** END WRITING THE CHAPTERS ********** */ /** ******* START WRITING THE METADATA ********* */ // Pick the main node for the descriptor var metadata = adventureData.getImsCPMetadata(); if (metadata != null) { var xmlMetadata = SerializeToXmlElement(new XmlDocument(), metadata); doc = new XmlDocument(); xmlMetadata = MetadataUtility.CleanXMLGarbage(doc, xmlMetadata); doc.AppendChild(xmlMetadata); doc.Save(folderName + "/imscpmetadata.xml"); } /** ******** END WRITING THE CHAPTERS ********** */ dataSaved = true; return(dataSaved); }
/** * Writes the daventure data into the given file. * * @param folderName * Folder where to write the data * @param adventureData * Adventure data to write in the file * @param valid * True if the adventure is valid (can be executed in the * engine), false otherwise * @return True if the operation was succesfully completed, false otherwise */ public static bool writeData(string folderName, AdventureDataControl adventureData, bool valid) { bool dataSaved = false; // Create the necessary elements for building the DOM doc = new XmlDocument(); // Delete the previous XML files in the root of the project dir //DirectoryInfo projectFolder = new DirectoryInfo(folderName); //if (projectFolder.Exists) //{ // foreach (FileInfo file in projectFolder.GetFiles()) // { // file.Delete(); // } // foreach (DirectoryInfo dir in projectFolder.GetDirectories()) // { // dir.Delete(true); // } //} // Add the special asset files // TODO AssetsController.addSpecialAssets(); /** ******* START WRITING THE DESCRIPTOR ********* */ // Pick the main node for the descriptor XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "no"); XmlDocumentType typeDescriptor = doc.CreateDocumentType("game-descriptor", "SYSTEM", "descriptor.dtd", null); doc.AppendChild(declaration); doc.AppendChild(typeDescriptor); if (!valid) { DOMWriterUtility.DOMWrite(doc, adventureData, new DescriptorDOMWriter.InvalidAdventureDataControlParam()); } else { DOMWriterUtility.DOMWrite(doc, adventureData); } // TODO re-add indentation //indentDOM(mainNode, 0); // Create the necessary elements for export the DOM into a XML file //transformer = tFactory.newTransformer(); //transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "descriptor.dtd"); // Create the output buffer, write the DOM and close it //fout = new FileOutputStream(folderName + "/descriptor.xml"); //writeFile = new OutputStreamWriter(fout, "UTF-8"); //transformer.transform(new DOMSource(doc), new StreamResult(writeFile)); //writeFile.close(); //fout.close(); doc.Save(folderName + "/descriptor.xml"); /** ******** END WRITING THE DESCRIPTOR ********** */ /** ******* START WRITING THE CHAPTERS ********* */ // Write every chapter XmlDocumentType typeChapter; int chapterIndex = 1; foreach (Chapter chapter in adventureData.getChapters()) { doc = new XmlDocument(); declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "no"); typeChapter = doc.CreateDocumentType("eAdventure", "SYSTEM", "eadventure.dtd", null); doc.AppendChild(declaration); doc.AppendChild(typeChapter); // Pick the main node of the chapter // TODO FIX THIS and use normal domwriter var chapterwriter = new ChapterDOMWriter(); DOMWriterUtility.DOMWrite(doc, chapter); // TODO re-add indentation //indentDOM(mainNode, 0); //TODO: testing //doc = new XmlDocument(); // Create the necessary elements for export the DOM into a XML file //transformer = tFactory.newTransformer(); //transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "eadventure.dtd"); // Create the output buffer, write the DOM and close it //fout = new FileOutputStream(folderName + "/chapter" + chapterIndex++ + ".xml"); //writeFile = new OutputStreamWriter(fout, "UTF-8"); //transformer.transform(new DOMSource(doc), new StreamResult(writeFile)); //writeFile.close(); //fout.close(); doc.Save(folderName + "/chapter" + chapterIndex++ + ".xml"); } /** ******** END WRITING THE CHAPTERS ********** */ // Update the zip files //File.umount( ); dataSaved = true; return(dataSaved); }