ResourceManager::ResourceManager() : taskPool(nullptr) , archive(nullptr) , handleManager(nullptr) , numResourcesQueuedLoad(0) , asynchronousLoading(true) { handleManager = HandleCreateManager( GetResourcesAllocator() ); if( !gs_ResourcesManager ) gs_ResourcesManager = this; if( !gs_ResourceHandleManager ) gs_ResourceHandleManager = handleManager; ReflectionHandleContext context; context.type = ReflectionGetType(Resource); context.handles = gs_ResourceHandleManager; context.serialize = ResourceHandleSerialize; context.deserialize = ResourceHandleFind; ReflectionHandleContextMap contextMap; ReflectionSetHandleContext(&contextMap, context); resourceFinishLoadMutex = Allocate(GetResourcesAllocator(), Mutex); resourceFinishLoad = Allocate(GetResourcesAllocator(), Condition); }
void SelectionPlugin::onUndoOperation( const UndoOperationPtr& operation ) { assert( operation != nullptr ); Class* klass = operation->getType(); if( !ClassInherits(klass, ReflectionGetType(SelectionOperation)) ) return; SelectionOperation* selection = RefCast<SelectionOperation>(operation).get(); selection->redo(); }
void InputManager::addDevice( InputDevice* device ) { if( !device ) { LogWarn( "Tried to add an invalid input device" ); return; } devices.push_back( device ); LogInfo( "Registered a new input device: '%s'", EnumGetValueName(ReflectionGetType(InputDeviceType), (int32)device->getType())); }
EditorFrame::EditorFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) , paneCtrl(nullptr) , toolbarCtrl(nullptr) , statusCtrl(nullptr) , notebookCtrl(nullptr) , eventManager(nullptr) , pluginManager(nullptr) , documentManager(nullptr) , engine(nullptr) , archive(nullptr) , input(nullptr) { gs_EditorInstance = this; CoreInitialize(); #ifdef EDITOR_OLD_UI documentManager = AllocateThis(DocumentManager); documentManager->onDocumentAdded.Connect(this, &EditorFrame::onDocumentAdded); documentManager->onDocumentRemoved.Connect(this, &EditorFrame::onDocumentRemoved); documentManager->onDocumentRenamed.Connect(this, &EditorFrame::onDocumentRenamed); #endif createPlugins(); #ifdef EDITOR_OLD_UI createUI(); #endif createEngine(); eventManager = AllocateThis(EventManager); #ifdef ENABLE_PLUGIN_MONO Plugin* monoPlugin = pluginManager->getPluginFromClass( ReflectionGetType(MonoPlugin) ); pluginManager->enablePlugin(monoPlugin); #endif #ifdef EDITOR_OLD_UI enablePlugins(); createToolbar(); createLastUI(); #endif Bind(wxEVT_IDLE, &EditorFrame::OnIdle, this); Bind(wxEVT_CLOSE_WINDOW, &EditorFrame::OnClose, this); auto projectPlugin = GetPlugin<ProjectPlugin>(); projectPlugin->createDocument(); }
void EditorFrame::createPlugins() { pluginManager = AllocateThis(PluginManager); // Find and instantiate plugins. std::vector<Plugin*> plugins; ClassCreateChilds(ReflectionGetType(EditorPlugin), AllocatorGetThis(), plugins); PluginsSortByPriority(plugins); pluginManager->registerPlugins(plugins); // Notify plugins that they have been registered. for( size_t i = 0; i < plugins.size(); i++ ) { EditorPlugin* plugin = (EditorPlugin*) plugins[i]; plugin->onPluginRegistered(); } }
void ResourcesPage::initControl() { rootId = AddRoot( "Resources", resGroupIcons[RG(General)] ); //resGroupIds[RG(General)] = AppendItem(rootId, "General", resGroupIcons[RG(General)]); Enum* enuhm = ReflectionGetType(ResourceGroup); const EnumValuesMap& values = enuhm->values; EnumValuesMap::const_iterator it; for( it = values.begin(); it != values.end(); it++ ) { ResourceGroup group = (ResourceGroup) it->second; resGroupIds[group] = AppendItem(rootId, it->first, resGroupIcons[group]); } Bind(wxEVT_COMMAND_TREE_SEL_CHANGED, &ResourcesPage::onItemChanged, this); Bind(wxEVT_COMMAND_TREE_ITEM_MENU, &ResourcesPage::onTreeItemMenu, this); Bind(wxEVT_COMMAND_MENU_SELECTED, &ResourcesPage::onCommandMenuSelected, this); }
wxBitmap* ConvertImageToBitmap( Image* image, const Path& fullPath ) { if( !image || !image->isLoaded() ) return nullptr; PixelFormat pf = image->getPixelFormat(); if( pf != PixelFormat::R8G8B8A8 ) { LogDebug("Invalid image format: %s", EnumGetValueName(ReflectionGetType(PixelFormat), (int32)pf)); return nullptr; } //wxBitmap* bmp = new wxBitmap; //bmp->Create(&image->getBuffer(), wxBITMAP_TYPE_ANY, image->getWidth(), image->getHeight(), 4); Stream* stream = StreamCreateFromFile(AllocatorGetHeap(), fullPath, StreamOpenMode::Read); if( !stream ) return nullptr; std::vector<byte> data; StreamRead(stream, data); wxMemoryInputStream mem(&data[0], data.size()); wxImage img(mem); img.Rescale(32, 32); StreamDestroy(stream); #if 0 const wxSize& size = GetSize(); if( img.GetWidth() > size.GetWidth() || img.GetHeight() > size.GetHeight() ) { img.Rescale( size.GetWidth(), size.GetHeight() ); } #endif wxBitmap* bmp = new wxBitmap(img); return bmp; }
Enum* UserMessageHandler::getMessagesEnum() { return ReflectionGetType(UserMessageIds); }
void Camera::cull( RenderBlock& block, const Entity* entity ) { if( !entity ) return; // Try to see if this is a Group-derived node. Class* klass = entity->getType(); if( ClassInherits(klass, ReflectionGetType(Group)) ) { const Group* group = (Group*) entity; const Array<EntityPtr>& entities = group->getEntities(); // Cull the children entities recursively. for( size_t i = 0; i < entities.size(); i++ ) { const Entity* child = entities[i].get(); cull( block, child ); } return; } // If this is a visible.renderable object, then we perform frustum culling // and then we push it to a list of things passed later to the renderer. //entity->onPreCull(); if( !entity->isVisible() ) return; const Transform* transform = entity->getTransform().get(); const BoundingBox& box = transform->getWorldBoundingVolume(); bool isCulled = !entity->getTag(Tags::NonCulled); if( frustumCulling && isCulled && !frustum.intersects(box) ) return; #pragma TODO("Fix multiple geometry instancing") const Array<GeometryPtr>& geoms = entity->getGeometry(); for( size_t i = 0; i < geoms.size(); i++ ) { const GeometryPtr& geometry = geoms[i]; geometry->appendRenderables( block.renderables, transform ); } #if 0 const LightPtr& light = entity->getComponent<Light>(); if( light ) { LightState ls; ls.light = light.get(); ls.transform = transform.get(); block.lights.pushBack( ls ); } #endif #ifdef BUILD_DEBUG const ComponentMap& components = entity->getComponents(); for( auto it = components.begin(); it != components.end(); it++ ) { const ComponentPtr& component = it->value; component->onPreRender(*this); if( !component->isDebugRenderableVisible() ) continue; DebugDrawFlags flags = (DebugDrawFlags) 0; component->onDebugDraw(drawer, flags); } #endif }