mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
Exposed MapOptions for plugins and added funtions to read and write settings in the map options (dbs file)
This commit is contained in:
parent
6f63595fb3
commit
6661d8fb81
3 changed files with 56 additions and 16 deletions
|
@ -362,6 +362,9 @@ namespace CodeImp.DoomBuilder.Config
|
||||||
// WritePluginSetting
|
// WritePluginSetting
|
||||||
public bool WritePluginSetting(string setting, object settingvalue) { return cfg.WriteSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, settingvalue); }
|
public bool WritePluginSetting(string setting, object settingvalue) { return cfg.WriteSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, settingvalue); }
|
||||||
|
|
||||||
|
// DeletePluginSetting
|
||||||
|
public bool DeletePluginSetting(string setting) { return cfg.DeleteSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting); }
|
||||||
|
|
||||||
// ReadSetting
|
// ReadSetting
|
||||||
internal string ReadSetting(string setting, string defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
internal string ReadSetting(string setting, string defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
||||||
internal int ReadSetting(string setting, int defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
internal int ReadSetting(string setting, int defaultsetting) { return cfg.ReadSetting(setting, defaultsetting); }
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace CodeImp.DoomBuilder
|
||||||
public string FilePathName { get { return filepathname; } }
|
public string FilePathName { get { return filepathname; } }
|
||||||
public string FileTitle { get { return filetitle; } }
|
public string FileTitle { get { return filetitle; } }
|
||||||
public string TempPath { get { return temppath; } }
|
public string TempPath { get { return temppath; } }
|
||||||
internal MapOptions Options { get { return options; } }
|
public MapOptions Options { get { return options; } }
|
||||||
public MapSet Map { get { return map; } }
|
public MapSet Map { get { return map; } }
|
||||||
public DataManager Data { get { return data; } }
|
public DataManager Data { get { return data; } }
|
||||||
public bool IsChanged { get { return changed | CheckScriptChanged(); } set { changed |= value; } }
|
public bool IsChanged { get { return changed | CheckScriptChanged(); } set { changed |= value; } }
|
||||||
|
|
|
@ -20,17 +20,19 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using CodeImp.DoomBuilder.Data;
|
using CodeImp.DoomBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.Config;
|
using CodeImp.DoomBuilder.Config;
|
||||||
|
using CodeImp.DoomBuilder.Plugins;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace CodeImp.DoomBuilder.Map
|
namespace CodeImp.DoomBuilder.Map
|
||||||
{
|
{
|
||||||
internal sealed class MapOptions
|
public sealed class MapOptions
|
||||||
{
|
{
|
||||||
#region ================== Constants
|
#region ================== Constants
|
||||||
|
|
||||||
|
@ -61,12 +63,12 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Properties
|
#region ================== Properties
|
||||||
|
|
||||||
public string ConfigFile { get { return configfile; } set { configfile = value; } }
|
internal string ConfigFile { get { return configfile; } set { configfile = value; } }
|
||||||
public DataLocationList Resources { get { return resources; } }
|
internal DataLocationList Resources { get { return resources; } }
|
||||||
public bool StrictPatches { get { return strictpatches; } set { strictpatches = value; } }
|
internal bool StrictPatches { get { return strictpatches; } set { strictpatches = value; } }
|
||||||
public List<string> ScriptFiles { get { return scriptfiles; } set { scriptfiles = value; } }
|
internal List<string> ScriptFiles { get { return scriptfiles; } set { scriptfiles = value; } }
|
||||||
public string PreviousName { get { return previousname; } set { previousname = value; } }
|
internal string PreviousName { get { return previousname; } set { previousname = value; } }
|
||||||
public string CurrentName
|
internal string CurrentName
|
||||||
{
|
{
|
||||||
get { return currentname; }
|
get { return currentname; }
|
||||||
|
|
||||||
|
@ -81,6 +83,8 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string LevelName { get { return currentname; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ================== Constructor / Disposer
|
#region ================== Constructor / Disposer
|
||||||
|
@ -155,8 +159,41 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
|
|
||||||
#region ================== Methods
|
#region ================== Methods
|
||||||
|
|
||||||
|
// This makes the path prefix for the given assembly
|
||||||
|
private string GetPluginPathPrefix(Assembly asm)
|
||||||
|
{
|
||||||
|
Plugin p = General.Plugins.FindPluginByAssembly(asm);
|
||||||
|
return "plugins." + p.Name.ToLowerInvariant() + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadPluginSetting
|
||||||
|
public string ReadPluginSetting(string setting, string defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public int ReadPluginSetting(string setting, int defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public float ReadPluginSetting(string setting, float defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public short ReadPluginSetting(string setting, short defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public long ReadPluginSetting(string setting, long defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public bool ReadPluginSetting(string setting, bool defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public byte ReadPluginSetting(string setting, byte defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
public IDictionary ReadPluginSetting(string setting, IDictionary defaultsetting) { return mapconfig.ReadSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, defaultsetting); }
|
||||||
|
|
||||||
|
// ReadPluginSetting with specific plugin
|
||||||
|
public string ReadPluginSetting(string pluginname, string setting, string defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public int ReadPluginSetting(string pluginname, string setting, int defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public float ReadPluginSetting(string pluginname, string setting, float defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public short ReadPluginSetting(string pluginname, string setting, short defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public long ReadPluginSetting(string pluginname, string setting, long defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public bool ReadPluginSetting(string pluginname, string setting, bool defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public byte ReadPluginSetting(string pluginname, string setting, byte defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
public IDictionary ReadPluginSetting(string pluginname, string setting, IDictionary defaultsetting) { return mapconfig.ReadSetting(pluginname.ToLowerInvariant() + "." + setting, defaultsetting); }
|
||||||
|
|
||||||
|
// WritePluginSetting
|
||||||
|
public bool WritePluginSetting(string setting, object settingvalue) { return mapconfig.WriteSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting, settingvalue); }
|
||||||
|
|
||||||
|
// DeletePluginSetting
|
||||||
|
public bool DeletePluginSetting(string setting) { return mapconfig.DeleteSetting(GetPluginPathPrefix(Assembly.GetCallingAssembly()) + setting); }
|
||||||
|
|
||||||
// This stores the map options in a configuration
|
// This stores the map options in a configuration
|
||||||
public void WriteConfiguration(string settingsfile)
|
internal void WriteConfiguration(string settingsfile)
|
||||||
{
|
{
|
||||||
Configuration wadcfg;
|
Configuration wadcfg;
|
||||||
|
|
||||||
|
@ -190,7 +227,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// This adds a resource location and returns the index where the item was added
|
// This adds a resource location and returns the index where the item was added
|
||||||
public int AddResource(DataLocation res)
|
internal int AddResource(DataLocation res)
|
||||||
{
|
{
|
||||||
// Get a fully qualified path
|
// Get a fully qualified path
|
||||||
res.location = Path.GetFullPath(res.location);
|
res.location = Path.GetFullPath(res.location);
|
||||||
|
@ -213,21 +250,21 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// This clears all reasource
|
// This clears all reasource
|
||||||
public void ClearResources()
|
internal void ClearResources()
|
||||||
{
|
{
|
||||||
// Clear list
|
// Clear list
|
||||||
resources.Clear();
|
resources.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This removes a resource by index
|
// This removes a resource by index
|
||||||
public void RemoveResource(int index)
|
internal void RemoveResource(int index)
|
||||||
{
|
{
|
||||||
// Remove the item
|
// Remove the item
|
||||||
resources.RemoveAt(index);
|
resources.RemoveAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This copies resources from a list
|
// This copies resources from a list
|
||||||
public void CopyResources(DataLocationList fromlist)
|
internal void CopyResources(DataLocationList fromlist)
|
||||||
{
|
{
|
||||||
// Clear this list
|
// Clear this list
|
||||||
resources.Clear();
|
resources.Clear();
|
||||||
|
@ -247,7 +284,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// This returns the UDMF field type
|
// This returns the UDMF field type
|
||||||
public int GetUniversalFieldType(string elementname, string fieldname, int defaulttype)
|
internal int GetUniversalFieldType(string elementname, string fieldname, int defaulttype)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
|
@ -263,7 +300,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// This stores the UDMF field type
|
// This stores the UDMF field type
|
||||||
public void SetUniversalFieldType(string elementname, string fieldname, int type)
|
internal void SetUniversalFieldType(string elementname, string fieldname, int type)
|
||||||
{
|
{
|
||||||
// Check if the type of this field is not set in the game configuration
|
// Check if the type of this field is not set in the game configuration
|
||||||
if(General.Map.Config.ReadSetting("universalfields." + elementname + "." + fieldname + ".type", -1) == -1)
|
if(General.Map.Config.ReadSetting("universalfields." + elementname + "." + fieldname + ".type", -1) == -1)
|
||||||
|
@ -274,7 +311,7 @@ namespace CodeImp.DoomBuilder.Map
|
||||||
}
|
}
|
||||||
|
|
||||||
// This removes all UDMF field types
|
// This removes all UDMF field types
|
||||||
public void ForgetUniversalFieldTypes()
|
internal void ForgetUniversalFieldTypes()
|
||||||
{
|
{
|
||||||
mapconfig.DeleteSetting("fieldtypes");
|
mapconfig.DeleteSetting("fieldtypes");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue