public void WriteDialogJson(JsonWriter output, string key, AGS.Types.Dialog dialog) { if (dialog == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("scriptName", dialog.Name); output.WriteValue("showTextParser", dialog.ShowTextParser); using (output.BeginArray("options")) { foreach (AGS.Types.DialogOption option in dialog.Options) { WriteDialogOptionJson(output, option); } } } }
private void WriteView(JsonWriter output, string key, AGS.Types.View view) { if (view == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { using (output.BeginArray("loops")) { foreach (AGS.Types.ViewLoop loop in view.Loops) { WriteLoopJson(output, loop); } } } }
public void WriteSettingsJson(JsonWriter output, string key) { using (output.BeginObject(key)) { AGS.Types.Settings settings = editor.CurrentGame.Settings; switch (settings.ColorDepth) { case AGS.Types.GameColorDepth.Palette: output.WriteValue("colorDepth", 8); break; case AGS.Types.GameColorDepth.HighColor: output.WriteValue("colorDepth", 16); break; case AGS.Types.GameColorDepth.TrueColor: output.WriteValue("colorDepth", 32); break; default: throw new Exception("unknown color depth: " + settings.ColorDepth); } switch (settings.Resolution) { case AGS.Types.GameResolutions.R320x200: output.WriteValue("width", 320); output.WriteValue("height", 200); break; case AGS.Types.GameResolutions.R320x240: output.WriteValue("width", 320); output.WriteValue("height", 240); break; case AGS.Types.GameResolutions.R640x400: output.WriteValue("width", 640); output.WriteValue("height", 400); break; case AGS.Types.GameResolutions.R640x480: output.WriteValue("width", 640); output.WriteValue("height", 480); break; case AGS.Types.GameResolutions.R800x600: output.WriteValue("width", 800); output.WriteValue("height", 600); break; case AGS.Types.GameResolutions.R1024x768: output.WriteValue("width", 1024); output.WriteValue("height", 768); break; default: throw new Exception("unknown resolution: " + settings.Resolution); } using (output.BeginObject("skipSpeech")) { switch (settings.SkipSpeech) { case AGS.Types.SkipSpeechStyle.MouseOrKeyboardOrTimer: output.WriteValue("mouse", true); output.WriteValue("keyboard", true); output.WriteValue("timer", true); break; case AGS.Types.SkipSpeechStyle.MouseOrKeyboard: output.WriteValue("mouse", true); output.WriteValue("keyboard", true); output.WriteValue("timer", false); break; case AGS.Types.SkipSpeechStyle.MouseOnly: output.WriteValue("mouse", true); output.WriteValue("keyboard", false); output.WriteValue("timer", true); break; case AGS.Types.SkipSpeechStyle.KeyboardOnly: output.WriteValue("mouse", false); output.WriteValue("keyboard", true); output.WriteValue("timer", false); break; case AGS.Types.SkipSpeechStyle.TimerOnly: output.WriteValue("mouse", false); output.WriteValue("keyboard", false); output.WriteValue("timer", true); break; } } output.WriteValue("name", settings.GameName); output.WriteValue("maxScore", settings.MaximumScore); output.WriteValue("mouseWheelSupport", settings.MouseWheelEnabled); output.WriteValue("gameWideSpeechAnimationSpeed", settings.LegacySpeechAnimationSpeed); output.WriteValue("useLowResCoordinates", settings.UseLowResCoordinatesInScript); output.WriteValue("autoMoveLookMode", settings.WalkInLookMode); output.WriteValue("autoMoveWalkMode", settings.AutoMoveInWalkMode); output.WriteValue("turnBeforeWalking", settings.TurnBeforeWalking); output.WriteValue("turnToFaceDirection", settings.TurnBeforeFacing); output.WriteValue("debug", settings.DebugMode); output.WriteValue("dialogBulletPointImage", settings.DialogOptionsBullet); output.WriteValue("dialogGapPixels", settings.DialogOptionsGap); output.WriteValue("numberDialogOptions", settings.NumberDialogOptions); output.WriteValue("dialogOptionsUpwards", settings.DialogOptionsBackwards); output.WriteValue("animateDuringDialogOptions", settings.RunGameLoopsWhileDialogOptionsDisplayed); output.WriteValue("speechPortraitSide", EnumName(settings.SpeechPortraitSide)); output.WriteValue("speechStyle", EnumName(settings.SpeechStyle)); output.WriteValue("dialogOptionsGui", settings.DialogOptionsGUI); output.WriteValue("multipleInventoryIcons", settings.DisplayMultipleInventory); AGS.Types.InventoryHotspotMarker marker = settings.InventoryHotspotMarker; if (marker == null) { output.WriteNull("inventoryItemCursorHotspotMarker"); } else { switch (marker.Style) { case AGS.Types.InventoryHotspotMarkerStyle.None: output.WriteNull("inventoryItemCursorHotspotMarker"); break; case AGS.Types.InventoryHotspotMarkerStyle.Sprite: using (output.BeginObject("inventoryItemCursorHotspotMarker")) { output.WriteValue("type", "sprite"); output.WriteValue("image", marker.Image); } break; case AGS.Types.InventoryHotspotMarkerStyle.Crosshair: using (output.BeginObject("inventoryItemCursorHotspotMarker")) { output.WriteValue("type", "crosshair"); output.WriteValue("crosshairColor", marker.CrosshairColor); output.WriteValue("dotColor", marker.DotColor); } break; default: throw new Exception("Unknown InventoryHotspotMarkerStyle: " + marker.Style); } } output.WriteValue("overrideInventoryWindowClick", settings.HandleInvClicksInScript); output.WriteValue("inventoryItemCursor", settings.InventoryCursors); output.WriteValue("scoreSound", settings.PlaySoundOnScore); output.WriteValue("alwaysDisplaySpeech", settings.AlwaysDisplayTextAsSpeech); output.WriteValue("antiAliasTtf", settings.AntiAliasFonts); output.WriteValue("textWindowGui", settings.TextWindowGUI); output.WriteValue("thoughtBubbleGui", settings.ThoughtGUI); output.WriteValue("fontsHiRes", settings.FontsForHiRes); output.WriteValue("gameTextLeftToRight", settings.BackwardsText); output.WriteValue("roomTransition", EnumName(settings.RoomTransition)); output.WriteValue("guiAlphaStyle", EnumName(settings.GUIAlphaStyle)); output.WriteValue("pixelPerfect", settings.PixelPerfect); output.WriteValue("whenInterfaceDisabled", EnumName(settings.WhenInterfaceDisabled)); } }
public void WriteLoopJson(JsonWriter output, string key, AGS.Types.ViewLoop loop) { if (loop == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("runNextLoop", loop.RunNextLoop); using (output.BeginArray("frames")) { foreach (AGS.Types.ViewFrame frame in loop.Frames) { WriteFrameJson(output, frame); } } } }
public void WriteMouseCursorJson(JsonWriter output, string key, AGS.Types.MouseCursor cursor) { if (cursor == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("animate", cursor.Animate); output.WriteValue("animateOnlyOnHotspots", cursor.AnimateOnlyOnHotspots); output.WriteValue("animateOnlyWhenMoving", cursor.AnimateOnlyWhenMoving); output.WriteValue("image", cursor.Image); output.WriteValue("view", cursor.View); output.WriteValue("hotspotX", cursor.HotspotX); output.WriteValue("hotspotY", cursor.HotspotY); output.WriteValue("name", cursor.Name); output.WriteValue("standardMode", cursor.StandardMode); } }
public void WriteRoomObjectJson(JsonWriter output, string key, AGS.Types.RoomObject obj) { if (obj == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("baseline", obj.Baseline); output.WriteValue("scriptName", obj.Name); output.WriteValue("name", obj.Description); output.WriteValue("image", obj.Image); output.WriteValue("useRoomAreaLighting", obj.UseRoomAreaLighting); output.WriteValue("useRoomAreaScaling", obj.UseRoomAreaScaling); output.WriteValue("x", obj.StartX); output.WriteValue("y", obj.StartY); output.WriteValue("visible", obj.Visible); WriteCustomPropertiesJson(output, "properties", obj.Properties); WriteInteractionsJson(output, "clickModeHandlers", obj.Interactions); } }
public void WriteGuiJson(JsonWriter output, string key, AGS.Types.GUI gui) { if (gui == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("scriptName", gui.Name); output.WriteValue("backgroundColor", gui.BackgroundColor); output.WriteValue("backgroundImage", gui.BackgroundImage); if (gui is AGS.Types.NormalGUI) { output.WriteValue("type", "normal"); AGS.Types.NormalGUI normalGui = (AGS.Types.NormalGUI)gui; output.WriteValue("borderColor", normalGui.BorderColor); output.WriteValue("clickable", normalGui.Clickable); output.WriteValue("left", normalGui.Left); output.WriteValue("top", normalGui.Top); output.WriteValue("width", normalGui.Width); output.WriteValue("height", normalGui.Height); output.WriteValue("onClick", normalGui.OnClick); output.WriteValue("popupYPos", normalGui.PopupYPos); output.WriteValue("transparency", normalGui.Transparency); switch (normalGui.Visibility) { case AGS.Types.GUIVisibility.MouseYPos: output.WriteValue("visibility", "mouseYPos"); break; case AGS.Types.GUIVisibility.Normal: output.WriteValue("visibility", "normal"); break; case AGS.Types.GUIVisibility.NormalButInitiallyOff: output.WriteValue("visibility", "normalButInitiallyOff"); break; case AGS.Types.GUIVisibility.Persistent: output.WriteValue("visibility", "persistent"); break; case AGS.Types.GUIVisibility.PopupModal: output.WriteValue("visibility", "popupModal"); break; default: throw new Exception("Unknown GUIVisibility: " + normalGui.Visibility); } output.WriteValue("zOrder", normalGui.ZOrder); } else if (gui is AGS.Types.TextWindowGUI) { output.WriteValue("type", "textWindow"); AGS.Types.TextWindowGUI textWindowGui = (AGS.Types.TextWindowGUI)gui; output.WriteValue("borderColor", textWindowGui.BorderColor); output.WriteValue("textColor", textWindowGui.TextColor); } else { throw new Exception("Unknown GUI Type: " + gui); } using (output.BeginArray("controls")) { foreach (AGS.Types.GUIControl control in gui.Controls) { WriteGuiControlJson(output, control); } } } }
private void WriteFontJson(JsonWriter output, string key, AgsFont font) { if (font == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { using (output.BeginArray("chars")) { foreach (AgsFontChar c in font.Chars) { WriteFontCharJson(output, c); } } } }
public void WriteFrameJson(JsonWriter output, string key, AGS.Types.ViewFrame frame) { if (frame == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("image", frame.Image); output.WriteValue("delay", frame.Delay); output.WriteValue("flipped", frame.Flipped); output.WriteValue("sound", frame.Sound); } }
public void WriteRoomDefJson(JsonWriter output, string key) { AGS.Types.ILoadedRoom room = editor.RoomController.CurrentRoom; if (room == null) { output.WriteNull(key); return; } AGS.Types.IRoom room2 = null; for (int i = 0; i < editor.CurrentGame.Rooms.Count; i++) { if (editor.CurrentGame.Rooms[i].Number == room.Number) { room2 = editor.CurrentGame.Rooms[i]; } } if (room2 == null) { throw new Exception("Room #" + room.Number + " not found in the rooms list!"); } using (output.BeginObject(key)) { output.WriteValue("game", GetCurrentGameGuid()); output.WriteValue("name", room2.Description); output.WriteValue("number", room.Number); output.WriteValue("stateSaving", room2.StateSaving); output.WriteValue("bottomEdgeY", room.BottomEdgeY); output.WriteValue("leftEdgeX", room.LeftEdgeX); output.WriteValue("rightEdgeX", room.RightEdgeX); output.WriteValue("topEdgeY", room.TopEdgeY); output.WriteValue("backgroundAnimationDelay", room.BackgroundAnimationDelay); output.WriteValue("legacyMusicVolumeAdjustment", EnumName(room.MusicVolumeAdjustment)); output.WriteValue("playerCharacterView", room.PlayerCharacterView); output.WriteValue("colorDepth", room.ColorDepth); output.WriteValue("width", room.Width); output.WriteValue("height", room.Height); output.WriteValue("numBackgrounds", room.BackgroundCount); Dictionary<int,bool> usedHotspots; Dictionary<int,bool> usedRegions; Dictionary<int,bool> usedWalkables; Dictionary<int,bool> usedWalkBehinds; using (output.BeginObject("masks")) { usedHotspots = WriteRoomMaskJson(output, "hotspots", AGS.Types.RoomAreaMaskType.Hotspots); usedRegions = WriteRoomMaskJson(output, "regions", AGS.Types.RoomAreaMaskType.Regions); usedWalkables = WriteRoomMaskJson(output, "walkableAreas", AGS.Types.RoomAreaMaskType.WalkableAreas); usedWalkBehinds = WriteRoomMaskJson(output, "walkBehinds", AGS.Types.RoomAreaMaskType.WalkBehinds); } using (output.BeginArray("hotspots")) { foreach (AGS.Types.RoomHotspot hs in room.Hotspots) { WriteRoomHotspotJson(output, hs, usedHotspots.ContainsKey(hs.ID)); } } using (output.BeginArray("objects")) { foreach (AGS.Types.RoomObject obj in room.Objects) { WriteRoomObjectJson(output, obj); } } using (output.BeginArray("walkbehinds")) { foreach (AGS.Types.RoomWalkBehind wb in room.WalkBehinds) { WriteRoomWalkbehindJson(output, wb, usedWalkBehinds.ContainsKey(wb.ID)); } } using (output.BeginArray("walkableAreas")) { foreach (AGS.Types.RoomWalkableArea area in room.WalkableAreas) { WriteRoomWalkableAreaJson(output, area, usedWalkables.ContainsKey(area.ID)); } } using (output.BeginArray("regions")) { foreach (AGS.Types.RoomRegion reg in room.Regions) { WriteRoomRegionJson(output, reg, usedRegions.ContainsKey(reg.ID)); } } WriteCustomPropertiesJson(output, "properties", room.Properties); } }
private void WriteFontCharJson(JsonWriter output, string key, AgsFontChar c) { if (c == null || c.Width == 0 || c.Height == 0) { output.WriteNull(key); return; } using (output.BeginObject(key)) { if (c.Width > 0 && c.Height > 0) { output.WriteValue("s", GameImageSheets.IndexOf(c.OwningSheet)); output.WriteValue("n", c.EntryNumber); if (c.Advance != c.Width) { output.WriteValue("a", c.Advance); } } } }
public void WriteRoomWalkbehindJson(JsonWriter output, string key, AGS.Types.RoomWalkBehind wb, bool used) { if (wb == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("used", used); output.WriteValue("baseline", wb.Baseline); } }
public void WriteRoomWalkableAreaJson(JsonWriter output, string key, AGS.Types.RoomWalkableArea area, bool used) { if (area == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("used", used); output.WriteValue("areaSpecificView", area.AreaSpecificView); output.WriteValue("maxScalingLevel", area.MaxScalingLevel); output.WriteValue("minScalingLevel", area.MinScalingLevel); output.WriteValue("scalingLevel", area.ScalingLevel); output.WriteValue("useContinuousScaling", area.UseContinuousScaling); } }
public void WriteRoomRegionJson(JsonWriter output, string key, AGS.Types.RoomRegion reg, bool used) { if (reg == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("used", used); output.WriteValue("blueTint", reg.BlueTint); output.WriteValue("greenTint", reg.GreenTint); output.WriteValue("lightLevel", reg.LightLevel); output.WriteValue("redTint", reg.RedTint); output.WriteValue("tintSaturation", reg.TintSaturation); output.WriteValue("useColorTint", reg.UseColourTint); WriteInteractionsJson(output, "interactions", reg.Interactions); } }
public void WriteDialogOptionJson(JsonWriter output, string key, AGS.Types.DialogOption option) { if (option == null) { output.WriteNull(); return; } using (output.BeginObject(key)) { output.WriteValue("text", option.Text); output.WriteValue("show", option.Show); output.WriteValue("say", option.Say); } }
public void WriteGuiControlJson(JsonWriter output, string key, AGS.Types.GUIControl control) { if (control == null) { output.WriteNull(key); return; } using (output.BeginObject(key)) { output.WriteValue("scriptName", control.Name); output.WriteValue("left", control.Left); output.WriteValue("top", control.Top); output.WriteValue("width", control.Width); output.WriteValue("height", control.Height); output.WriteValue("zOrder", control.ZOrder); switch (control.ControlType) { case "Label": output.WriteValue("type", "label"); AGS.Types.GUILabel label = (AGS.Types.GUILabel)control; output.WriteValue("font", label.Font); output.WriteValue("text", label.Text); output.WriteValue("textAlignment", EnumName(label.TextAlignment)); output.WriteValue("textColor", label.TextColor); break; case "Button": output.WriteValue("type", "button"); AGS.Types.GUIButton button = (AGS.Types.GUIButton)control; output.WriteValue("font", button.Font); output.WriteValue("buttonAction", EnumName(button.ClickAction)); output.WriteValue("clipImage", button.ClipImage); output.WriteValue("image", button.Image); output.WriteValue("mouseoverImage", button.MouseoverImage); output.WriteValue("newModeNumber", button.NewModeNumber); output.WriteValue("onClick", button.OnClick); output.WriteValue("pushedImage", button.PushedImage); output.WriteValue("text", button.Text); output.WriteValue("textAlignment", EnumName(button.TextAlignment)); output.WriteValue("textColor", button.TextColor); break; case "InventoryWindow": output.WriteValue("type", "inventoryWindow"); AGS.Types.GUIInventory inv = (AGS.Types.GUIInventory)control; output.WriteValue("characterId", inv.CharacterID); output.WriteValue("itemHeight", inv.ItemHeight); output.WriteValue("itemWidth", inv.ItemWidth); break; case "ListBox": output.WriteValue("type", "listBpx"); AGS.Types.GUIListBox listBox = (AGS.Types.GUIListBox)control; output.WriteValue("font", listBox.Font); output.WriteValue("onSelectionChanged", listBox.OnSelectionChanged); output.WriteValue("selectedBackgroundColor", listBox.SelectedBackgroundColor); output.WriteValue("selectedTextColor", listBox.SelectedTextColor); output.WriteValue("showBorder", listBox.ShowBorder); output.WriteValue("showScrollArrows", listBox.ShowScrollArrows); output.WriteValue("textAlignment", EnumName(listBox.TextAlignment)); output.WriteValue("textColor", listBox.TextColor); break; case "Slider": output.WriteValue("type", "slider"); AGS.Types.GUISlider slider = (AGS.Types.GUISlider)control; output.WriteValue("backgroundImage", slider.BackgroundImage); output.WriteValue("handleImage", slider.HandleImage); output.WriteValue("handleOffset", slider.HandleOffset); output.WriteValue("maxValue", slider.MaxValue); output.WriteValue("minValue", slider.MinValue); output.WriteValue("onChange", slider.OnChange); output.WriteValue("value", slider.Value); break; case "TextBox": output.WriteValue("type", "textBox"); AGS.Types.GUITextBox textBox = (AGS.Types.GUITextBox)control; output.WriteValue("font", textBox.Font); output.WriteValue("onActivate", textBox.OnActivate); output.WriteValue("showBorder", textBox.ShowBorder); output.WriteValue("text", textBox.Text); output.WriteValue("textColor", textBox.TextColor); break; case "TextWindowEdge": output.WriteValue("type", "textWindowEdge"); AGS.Types.GUITextWindowEdge edge = (AGS.Types.GUITextWindowEdge)control; output.WriteValue("image", edge.Image); break; default: throw new Exception("Unknown GUI Control Type: " + control.ControlType); } } }
private void WriteSpritesJson(JsonWriter output, string key) { using (output.BeginArray(key)) { foreach (SpriteImageSheetEntry entry in spriteImageSheetEntries) { if (entry == null || entry.Width == 0 || entry.Height == 0) { output.WriteNull(); } else { using (output.BeginObject()) { output.WriteValue("s", GameImageSheets.IndexOf(entry.OwningSheet)); output.WriteValue("n", entry.EntryNumber); } } } } }
public void WriteRoomHotspotJson(JsonWriter output, string key, AGS.Types.RoomHotspot hs, bool used) { using (output.BeginObject(key)) { output.WriteValue("used", used); output.WriteValue("name", hs.Description); output.WriteValue("scriptName", hs.Name); WriteCustomPropertiesJson(output, "properties", hs.Properties); WriteInteractionsJson(output, "clickModeHandlers", hs.Interactions); if (hs.WalkToPoint == null) { output.WriteNull("walkToX"); output.WriteNull("walkToY"); } else { output.WriteValue("walkToX", hs.WalkToPoint.X); output.WriteValue("walkToY", hs.WalkToPoint.Y); } } }