bool csMovieRecorder::Initialize (iObjectRegistry* iobject_reg) { object_reg = iobject_reg; CS_INITIALIZE_EVENT_SHORTCUTS (object_reg); KeyboardEvent = csevKeyboardEvent (object_reg); // We need to receive keyboard events for our hotkeys, and the nothing // event for the actual movie recording. if (!keyEventHandler) { keyEventHandler.AttachNew (new KeyEventHandler (this)); } csRef<iEventQueue> q (csQueryRegistry<iEventQueue> (object_reg)); if (q != 0) { csEventID events[2] = { KeyboardEvent, CS_EVENTLIST_END }; q->RegisterListener (keyEventHandler, events); } if (!logicEventHandler) { logicEventHandler.AttachNew (new LogicEventHandler (this)); } if (q != 0) { csEventID events[2] = { Frame, CS_EVENTLIST_END }; q->RegisterListener (logicEventHandler, events); } if (!frameEventHandler) { frameEventHandler.AttachNew (new FrameEventHandler (this)); } if (q != 0) { csEventID events[2] = { Frame, CS_EVENTLIST_END }; q->RegisterListener (frameEventHandler, events); } // Unregister the normal virtual clock and register our own // replacement, hoping nobody will notice :) // // FIXME: This will work for the application when this plugin is // loaded in initialization, but some modules might see the // real VC. Additionally, this won't work at all if the app // loads us after the app gets a VC reference. if (!virtualClock) { virtualClock.AttachNew (new VirtualClock (this)); } realVirtualClock = csQueryRegistry<iVirtualClock> (object_reg); object_reg->Unregister(realVirtualClock, "iVirtualClock"); object_reg->Register(virtualClock, "iVirtualClock"); return true; }
bool Simple::OnInitialize(int /*argc*/, char* /*argv*/ []) { // RequestPlugins() will load all plugins we specify. In addition // it will also check if there are plugins that need to be loaded // from the config system (both the application config and CS or // global configs). In addition it also supports specifying plugins // on the commandline. if (!csInitializer::RequestPlugins(GetObjectRegistry(), CS_REQUEST_VFS, CS_REQUEST_OPENGL3D, CS_REQUEST_ENGINE, CS_REQUEST_FONTSERVER, CS_REQUEST_IMAGELOADER, CS_REQUEST_LEVELLOADER, CS_REQUEST_REPORTER, CS_REQUEST_REPORTERLISTENER, CS_REQUEST_PLUGIN( "crystalspace.script.python", iScript ), CS_REQUEST_END)) return ReportError("Failed to initialize plugins!"); // "Warm up" the event handler so it can interact with the world csBaseEventHandler::Initialize(GetObjectRegistry()); // Now we need to register the event handler for our application. // Crystal Space is fully event-driven. Everything (except for this // initialization) happens in an event. // Rather than simply handling all events, we subscribe to the // particular events we're interested in. csEventID events[] = { csevFrame (GetObjectRegistry()), csevKeyboardEvent (GetObjectRegistry()), CS_EVENTLIST_END }; if (!RegisterQueue(GetObjectRegistry(), events)) return ReportError("Failed to set up event handler!"); // Report success return true; }