コード例 #1
0
        public void SpawnEntityInWorld(MapObjectSpawnDescriptor dragData)
        {
            WLog.Info(LogCategory.EditorCore, null, "Caught object to be spawned {0} in scene: {1}", dragData, SelectedScene);

            // Meh.
            MapEntityLoader loader = new MapEntityLoader(m_editorCore, Map);

            // We can skip post-processing the entities via MapEntityLoader b/c that just does reference fixups, and
            // because this is a new entity there's no references so no point in trying to fix them up.
            var newEnt = loader.CreateEntity(dragData);

            if (SelectedScene is Stage)
            {
                MapLoader.PostProcessStage((Stage)SelectedScene, new List <MapEntityLoader.RawMapEntity>(new[] { newEnt }));
            }

            if (SelectedScene is Room)
            {
                MapLoader.PostProcessRoom((Room)SelectedScene, new List <MapEntityLoader.RawMapEntity>(new[] { newEnt }));
            }

            // meh more hacks.
            foreach (var ent in SelectedScene.Entities)
            {
                ent.World = this;
            }
        }
コード例 #2
0
ファイル: EditorCore.cs プロジェクト: CryZe/WindEditor2
        public void LoadMapFromDirectory(string folderPath)
        {
            if (string.IsNullOrEmpty(folderPath))
            {
                throw new ArgumentException("You must specify a folder to load from directory!");
            }

            if (LoadedScene != null)
            {
                throw new InvalidOperationException("There is already a map loaded, call UnloadMap() first!");
            }

            MapLoader mapLoader = new MapLoader();
            Map       newMap    = null;

#if DEBUG
            newMap = mapLoader.CreateFromDirectory(m_mainWorld, this, folderPath);
#else
            try
            {
                newMap = mapLoader.CreateFromDirectory(m_mainWorld, this, folderPath);
            }
            catch (Exception ex)
            {
                WLog.Error(LogCategory.EditorCore, null, "Exception while loading map: " + ex.ToString());
            }
#endif

            LoadedScene = newMap;
            GetWorldByName("main").Map = newMap;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: EditorCore.cs プロジェクト: CryZe/WindEditor2
        private void LoadEditorTemplates()
        {
            string executionPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            WLog.Info(LogCategory.EditorCore, null, "Loading JSON templates from {0}.", executionPath);

            string entityDescriptorFolder = executionPath + "/WindWaker/Templates/MapEntityData/";
            string objectDescriptorFolder = executionPath + "/WindWaker/Templates/ObjectData/";

            Templates.LoadTemplates(entityDescriptorFolder, objectDescriptorFolder);
        }
コード例 #5
0
ファイル: EditorCore.cs プロジェクト: CryZe/WindEditor2
        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);
        }
コード例 #6
0
ファイル: EditorCore.cs プロジェクト: CryZe/WindEditor2
        public EditorCore()
        {
            WLog.Info(LogCategory.EditorCore, null, "Initializing Editor Core...");
            m_stdOutLogger = new StandardOutLogger();
            m_editorWorlds = new BindingList <WWorld>();
            Templates      = new TemplateManager();

            m_mainWorld = new WWorld("main", this);
            m_editorWorlds.Add(m_mainWorld);

            m_mainWorld.InitializeSystem();
            LoadEditorTemplates();

            WLog.Info(LogCategory.EditorCore, null, "Editor Core Initialized.");
        }
コード例 #7
0
ファイル: Input.cs プロジェクト: CryZe/WindEditor2
        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);
        }
コード例 #8
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);
            }
        }
コード例 #9
0
        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]);
            }
        }
コード例 #10
0
 public StandardOutLogger()
 {
     WLog.Subscribe(LogCategory.None, OnRecieveLoggerMessage, null);
 }