static void getSettings(WebResponse response) { SettingsInfo info = new SettingsInfo(); // Read the current graphics flags info.lensFlares = Scripting.GetUserSetting("Graphics/Enable Lensflares", false); info.volumetricScattering = Scripting.GetUserSetting("Graphics/Enable Volumetric Scattering", true); info.bloom = Scripting.GetUserSetting("Graphics/Enable Bloom", true); info.afterImage = Scripting.GetUserSetting("Graphics/Enable AfterImage", true); info.tonemapping = Scripting.GetUserSetting("Graphics/Enable Tonemapping", true); info.noise = Scripting.GetUserSetting("Graphics/Enable Noise", false); info.shadows = Scripting.GetUserSetting("Graphics/Enable Shadows", true); info.ssao = Scripting.GetUserSetting("Graphics/Enable SSAO", true); info.fog = Scripting.GetUserSetting("Graphics/Enable Fog", true); info.fxaa = Scripting.GetUserSetting("Graphics/Enable FXAA", true); // Currently, only the main screen can be set for fullscreen mode. info.fullscreen = Scripting.GetUserSettingString("WindowManager/Fullscreen", "-1") != "-1"; // Read the supported video modes List <string> modes = Rendering.GetSupportedVideoModes(); modes.Insert(0, "Native Resolution"); info.resolution = Scripting.GetUserSettingString("WindowManager/Resolution", "-1x-1"); if (info.resolution == "-1x-1") { info.resolution = "Native Resolution"; } info.supportedModes = modes.Distinct().ToArray(); double lod = (Scripting.GetUserSettingNumber("Graphics/Lod Falloff", 40.0) - 10.0) / 30.0; lod += Scripting.GetUserSettingNumber("Graphics/Min Lod Range", 0.0) / 30.0; if (lod < 0) { lod = 0; } if (lod > 2) { lod = 2; } info.lod = lod; // Serialize to json to be read by the gui StringWriter writer = new StringWriter(); JsonSerializer json = new JsonSerializer(); JsonTextWriter jsonWriter = new JsonTextWriter(writer); json.Formatting = Formatting.Indented; json.Serialize(jsonWriter, info); response.AddHeader("Content-Type", "application/json"); response.AppendBody(writer.GetStringBuilder().ToString()); }
void webInventory(WebRequest request, WebResponse response) { // Compile all relevant info for the gui into a GuiInfo instance and send it to the GUI client. GuiInfo info = new GuiInfo(); info.playerIsFrozen = player.IsFrozen; info.inventory = GuiInfo.GuiItem.FromItemCollection(player.Inventory.Items); foreach (var item in player.Inventory.QuickAccessItems) { if (item != null) { info.quickAccess.Add(item.Identifier); } else { info.quickAccess.Add(""); } } info.selection = player.Inventory.SelectionIndex; /* * foreach (CraftingRule cr in player.Inventory.DiscoveredRules) * { * if (info.inventory.ContainsKey(cr.Result.Identifier)) * { * GuiInfo.GuiItem item = info.inventory[cr.Result.Identifier]; * item.hasDiscoveredCraftingRule = true; * if (cr.CanBeDismantled) * item.canBeDismantled = true; * if (cr.IsCraftable(player.Inventory.Items.ItemFromIdentifier(item.identifier), player.Inventory.Items)) * { * item.canBeCrafted = true; * } * * item.craftingIngredients = new List<GuiInfo.GuiItem>(GuiInfo.GuiItem.FromItemCollection(cr.Ingredients).Values); * } * else * { * GuiInfo.GuiItem virtualItem = new GuiInfo.GuiItem(cr.Result); * virtualItem.quantity = 0; * virtualItem.hasDiscoveredCraftingRule = true; * * if (cr.IsCraftable(null, player.Inventory.Items)) * { * virtualItem.canBeCrafted = true; * } * * virtualItem.craftingIngredients = new List<GuiInfo.GuiItem>(GuiInfo.GuiItem.FromItemCollection(cr.Ingredients).Values); * * info.inventory.Add(cr.Result.Identifier, virtualItem); * } * } */ StringWriter writer = new StringWriter(); JsonTextWriter jsonWriter = new JsonTextWriter(writer); json.Formatting = Formatting.Indented; json.Serialize(jsonWriter, info); response.AddHeader("Content-Type", "application/json"); response.AppendBody(writer.GetStringBuilder().ToString()); }