Link updated.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
[Serializable]
public abstract class Preference
{
}
[Serializable]
public class Preference<T> : Preference
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Category { get; set; }
public T Value { get; set; }
}
public static IList<Preference> Deserialize(string filename)
{
using (XmlReader reader = new XmlTextReader(filename))
{
reader.ReadToDescendant("ArrayOfString");
XmlSerializer typeSer = new XmlSerializer(typeof(List<string>));
List<string> typeNames = (List<string>)typeSer.Deserialize(reader);
List<Type> types = new List<Type>();
foreach (var type in typeNames)
{
types.Add(Type.GetType(type));
}
reader.ReadToDescendant("preferences");
XmlSerializer deSerializer = new XmlSerializer(typeof(Preference), types.ToArray());
List<Preference> retvalue = new List<Preference>();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
if (reader.Name == "Preference")
{
retvalue.Add((Preference)deSerializer.Deserialize(reader));
}
break;
}
}
return retvalue;
}
}
public static void Serialize(IList<Preference> preferences, string filename)
{
List<Type> types = new List<Type>();
List<string> typeNames = new List<string>();
foreach (var pref in preferences)
{
var type = pref.GetType();
if (!types.Contains(type))
{
types.Add(type);
typeNames.Add(type.AssemblyQualifiedName);
}
}
XmlSerializer serializer = new XmlSerializer(typeof(Preference), types.ToArray());
XmlWriterSettings settings = new XmlWriterSettings()
{
Indent = true
};
using (XmlWriter writer = XmlWriter.Create(filename, settings))
{
writer.WriteStartElement("doc");
writer.WriteStartElement("types");
XmlSerializer typeSer = new XmlSerializer(typeNames.GetType());
typeSer.Serialize(writer, typeNames);
writer.WriteEndElement();
writer.WriteStartElement("preferences");
foreach (var pref in preferences)
{
serializer.Serialize(writer, pref);
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
}
}
Quote from: InCreator2K is going to release a shitty FPS in Q1 2012, they dare to call 'XCOM'.
Still waiting for next XCom
QuotebitComposer is currently working on a remake of Jagged Alliance 2, the best turn-based strategy game ever created by men. Of course it's not going to be turn-based.
and Jagged Alliance
Quote from: PumamanNo, but it would be possible to use a pure native library with a C-style API.
You won't be able to, due to the Native DLL. If the source code to that was available, does Mono have a mixed-mode Managed & Native C++ compiler that could build it?
Quote from: PumamanSeems that Mono doesn't support named pipes under Linux at the moment anyway.
The AGS Editor uses P/Invoke in some rare cases where I couldn't find a way of doing it with managed code. The Named Pipes exception that you mention is in .NET 3.5, but since I want the AGS Editor to continue to support .NET 2.0, we can't use this. (it would be feasible to just use that for a Linux port which would require a 3.5-version of Mono though, of course).
Quote from: lefticusAGS has P/Invokes into WinAPI (kernel32, user32, winmm). It might be possible to use the Wine libraries, but I'd rather replace them with managed code.
pInvoke is well supported in mono too, it's used by any library that exposes an existing C or C++ library to mono (ie, sdl, wxwidgets and more).
Quote from: lefticusAs I said, there's a managed solution:
Named pipes exist on unix too, the main problem would just be porting between the unix/windows methods for using named pipes.
Quote from: lefticusUnfortunately, the wrapper is a mixed-mode assembly (managed+native code) which doesn't work with Mono.
Also, it seems irrklang has support for linux too:
Quote from: GarageGothic on Thu 22/07/2010 16:01:19There's a significant overhead involved in calling the AGS API methods.
Would there be any considerable slowdowns in using the wrapper compared to straight C++?
private static int AddNumbers(int a, int b)
{
return a + b;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int AddNumbersDel(int a, int b);
public int EditorStartup(IAGSEditor editor)
{
editor.RegisterScriptHeader("import int AddNumbers(int, int);
");
return 0;
}
private AddNumbersDel del;
public void EngineStartup(IAGSEngine engine)
{
del = new AddNumbersDel(AddNumbers);
IntPtr address = Marshal.GetFunctionPointerForDelegate(del);
engine.RegisterScriptFunction("AddNumbers", address);
}
Quote from: Rulaman on Tue 29/06/2010 19:47:47Looks more like the offset of the footer (little endian).
the length is encoded in big endian and the upper byte is one bigger.
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
AppDomain.CurrentDomain.BaseDirectory
dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PluginInfo");
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.067 seconds with 19 queries.