private void handleEditInstanceBtnClick() { if (inspectView.SelectedGameObjects.Count > 0) { var selectedObject = inspectView.SelectedGameObjects[0]; var dialog = new InputDialog("Edit Object", WorldObjectSerializer.Serialize(selectedObject).ToString(Formatting.Indented)); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { inspectView.Deselect(); selectedObject.DisconnectFromWorld(); selectedObject.Destroy(); var newObject = WorldObjectSerializer.Deserialize(JObject.Parse(dialog.ResultText)); newObject.ConnectToWorld(); inspectView.SelectGameObject(newObject); } } else if (inspectView.SelectedWorldLink != null) { var SelectedWorldLink = inspectView.SelectedWorldLink; var dialog = new InputDialog("Edit Object", JToken.FromObject(SelectedWorldLink, SerializationUtils.Serializer).ToString(Formatting.Indented)); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { inspectView.Deselect(); var newWorldLink = SerializationUtils.Serializer.Deserialize <WorldLink>(new JTokenReader(JToken.Parse(dialog.ResultText))); SimulationGame.World.UpdateWorldLink(SelectedWorldLink, newWorldLink); } } }
protected static void Serialize(WorldPart worldPart, ref JObject jObject) { SerializationUtils.AddToObject(jObject, worldPart, worldPartType, serializeableProperties); // Serialize Ambient Objects JArray ambientObjects = new JArray(); if (worldPart.AmbientObjects != null) { foreach (var ambientObject in worldPart.AmbientObjects) { ambientObjects.Add(WorldObjectSerializer.Serialize(ambientObject)); } } jObject.Add("AmbientObjects", ambientObjects); // Serialize Hitable Objects JArray containedObjects = new JArray(); if (worldPart.ContainedObjects != null) { foreach (var containedObject in worldPart.ContainedObjects) { if (containedObject is DurableEntity) { continue; } containedObjects.Add(WorldObjectSerializer.Serialize(containedObject)); } } jObject.Add("ContainedObjects", containedObjects); }
public override void Update(GameTime gameTime) { if (SimulationGame.IsWorldBuilderOpen) { base.Update(gameTime); setSelectedButtonColor(); if (placementType != PlacementType.NoType && placementType != PlacementType.Inspect && placementType != PlacementType.WorldPartDetails) { switch (placementMode) { case PlacementMode.Manage: manageObjectList.Update(gameTime); if (manageObjectList.SelectedElement != null) { editBtn.Update(gameTime); createNewFromBtn.Update(gameTime); removeBtn.Update(gameTime); } break; case PlacementMode.ChooseTileset: tilesetSelectionList.Update(gameTime); break; case PlacementMode.CreateFromTileset: tileSetSelectionView.Update(gameTime); if (tileSetSelectionView.SelectedSpritePosition != null) { createBtn.Update(gameTime); createIfNotExistBtn.Update(gameTime); } break; } manageBtn.Update(gameTime); createFromJsonBtn.Update(gameTime); if (placementType != PlacementType.LivingEntityPlacement) { createFromTilesetBtn.Update(gameTime); } } else if (placementType == PlacementType.WorldPartDetails) { changePersistencyBtn.Update(gameTime); createWorldLinkBtn.Update(gameTime); createInteriorBtn.Update(gameTime); if (SimulationGame.Player.InteriorID != Interior.Outside) { changeInteriorDimensionsBtn.Update(gameTime); removeInteriorBtn.Update(gameTime); } var player = SimulationGame.Player; WorldPart currentWorldPart = player.InteriorID == Interior.Outside ? (WorldPart)SimulationGame.World.GetFromRealPoint((int)player.Position.X, (int)player.Position.Y) : SimulationGame.World.InteriorManager.Get(player.InteriorID); worldPartDetailsTextView.SetText( "CurrentBlock: " + player.BlockPosition.X + "," + player.BlockPosition.Y + "\n" + "IsPersistent: " + currentWorldPart.IsPersistent + "\n" + "InteriorID: " + player.InteriorID + "\n" + (player.InteriorID != Interior.Outside ? ("Dimensions: " + ((Interior)currentWorldPart).Dimensions + "\n") : "") ); worldPartDetailsTextView.Update(gameTime); } else if (placementType == PlacementType.Inspect) { if (inspectView.SelectedGameObjects.Count > 0) { selectedObjectDetailTextView.SetText(WorldObjectSerializer.Serialize(inspectView.SelectedGameObjects[0]).ToString(Formatting.Indented)); editInstanceBtn.Update(gameTime); removeInstanceBtn.Update(gameTime); showInstanceTypeBtn.Update(gameTime); } else if (inspectView.SelectedWorldLink != null) { selectedObjectDetailTextView.SetText(JToken.FromObject(inspectView.SelectedWorldLink, SerializationUtils.Serializer).ToString(Formatting.Indented)); editInstanceBtn.Update(gameTime); removeInstanceBtn.Update(gameTime); } selectedObjectDetailTextView.Update(gameTime); } if ((placementMode == PlacementMode.Manage && manageObjectList.SelectedElement != null) || (placementMode == PlacementMode.CreateFromTileset && tileSetSelectionView.SelectedObject != null)) { placeView.Update(gameTime); } else { inspectView.Update(gameTime); } } }