public static void Subscribe(LogCategory category, RecieveLogMessage callback, object contextFilter) { if (m_subscribers.Find(x => x.Category == category && x.Callback == callback && x.ContextFilter.Equals(contextFilter)) != null) { WLog.Warning(LogCategory.None, null, "Subscriber list already contains callback: {0}!", callback); } MessageSubscriber subscriber = new MessageSubscriber(category, callback, contextFilter); m_subscribers.Add(subscriber); }
public WWorld GetWorldByName(string worldName) { // Find the right world for this output foreach (WWorld world in m_editorWorlds) { if (string.Compare(world.Name, worldName, StringComparison.InvariantCultureIgnoreCase) == 0) { return(world); } } WLog.Warning(LogCategory.Rendering, null, "Recieved GetWorldByName for world {0}, but no world of that name exists. Ignoring.", worldName); return(null); }
private static int MouseButtonEnumToInt(MouseButton button) { switch (button) { case MouseButton.Left: return(0); case MouseButton.Right: return(1); case MouseButton.Middle: return(2); } WLog.Warning(LogCategory.EditorCore, null, "Unknown Mouse Button enum {0}, returning Left!", button); return(0); }
public void LoadTemplates(string entityDescriptorPath, string objectDescriptorPath) { // Load Entity Data, which describes the layout of various entities in a map. DirectoryInfo mapEntityDescriptorDirectory = new DirectoryInfo(entityDescriptorPath); MapEntityDataDescriptors = new List <MapEntityDataDescriptor>(); foreach (var file in mapEntityDescriptorDirectory.GetFiles()) { var template = JsonConvert.DeserializeObject <MapEntityDataDescriptor>(File.ReadAllText(file.FullName)); MapEntityDataDescriptors.Add(template); } // Then load the Object Data, which describes the layout of specific actors since their parameters change // depending on the actor used. DirectoryInfo objDataDI = new DirectoryInfo(objectDescriptorPath); MapObjectDataDescriptors = new List <MapObjectDataDescriptor>(); foreach (var file in objDataDI.GetFiles()) { var descriptor = JsonConvert.DeserializeObject <MapObjectDataDescriptor>(File.ReadAllText(file.FullName)); MapObjectDataDescriptors.Add(descriptor); if (descriptor.TechnicalName == "DEFAULT_TEMPLATE") { if (DefaultMapObjectDataDescriptor != null) { WLog.Warning(LogCategory.EntityLoading, null, "Found multiple default MapObjectDataDescriptors, ignoring."); continue; } DefaultMapObjectDataDescriptor = descriptor; } } if (DefaultMapObjectDataDescriptor == null) { throw new FileNotFoundException("Default MapObjectDataDescriptor not found!", objectDescriptorPath); } }
private static byte[] DecodeData(EndianBinaryReader stream, uint width, uint height, TextureFormats format, Palette imagePalette, PaletteFormats paletteFormat) { switch (format) { case TextureFormats.I4: return(DecodeI4(stream, width, height)); case TextureFormats.I8: return(DecodeI8(stream, width, height)); case TextureFormats.IA4: return(DecodeIA4(stream, width, height)); case TextureFormats.IA8: return(DecodeIA8(stream, width, height)); case TextureFormats.RGB565: return(DecodeRgb565(stream, width, height)); case TextureFormats.RGB5A3: return(DecodeRgb5A3(stream, width, height)); case TextureFormats.RGBA32: return(DecodeRgba32(stream, width, height)); case TextureFormats.C4: return(DecodeC4(stream, width, height, imagePalette, paletteFormat)); case TextureFormats.C8: return(DecodeC8(stream, width, height, imagePalette, paletteFormat)); case TextureFormats.CMPR: return(DecodeCmpr(stream, width, height)); case TextureFormats.C14X2: default: WLog.Warning(LogCategory.Textures, null, "Unsupported Binary Texture Image format {0}, unable to decode!", format); return(new byte[0]); } }