| 833 | } |
| 834 | |
| 835 | void CEntityScriptRegistry::LoadScripts() |
| 836 | { |
| 837 | IGame *game = GetIEditor()->GetGame(); |
| 838 | if (!game) |
| 839 | return; |
| 840 | |
| 841 | m_scripts.Clear(); |
| 842 | |
| 843 | EntityClass *entCls; |
| 844 | // Enumerate entity classes inside Game. |
| 845 | game->GetClassRegistry()->MoveFirst(); |
| 846 | do { |
| 847 | entCls = game->GetClassRegistry()->Next(); |
| 848 | if (entCls) |
| 849 | { |
| 850 | CEntityScript *script = new CEntityScript( entCls->ClassId,entCls->strClassName.c_str(),entCls->strScriptFile.c_str() ); |
| 851 | if (!entCls->strScriptFile.empty()) |
| 852 | script->SetUsable( true ); |
| 853 | Insert( script ); |
| 854 | } |
| 855 | } while (entCls); |
| 856 | |
| 857 | /* |
| 858 | int lastClassId = FIRST_ENTITY_CLASS_ID; |
| 859 | |
| 860 | ////////////////////////////////////////////////////////////////////////// |
| 861 | // Load class registry. |
| 862 | // Enumerate all XML files in Editor\ subfolder to look for EntityRegistry. |
| 863 | ////////////////////////////////////////////////////////////////////////// |
| 864 | |
| 865 | CString masterCD = GetIEditor()->GetMasterCDFolder(); |
| 866 | std::vector<CFileUtil::FileDesc> files; |
| 867 | CString dir = Path::AddBackslash(masterCD) + "Editor\\"; |
| 868 | CFileUtil::ScanDirectory( dir,"*.xml",files,false ); |
| 869 | |
| 870 | XmlParser parser; |
| 871 | |
| 872 | FILE *file; |
| 873 | file = fopen( "Scripts\\classreg1.lua","wt" ); |
| 874 | |
| 875 | for (int k = 0; k < files.size(); k++) |
| 876 | { |
| 877 | // Construct the full filepath of the current file |
| 878 | XmlNodeRef registry = parser.parse( dir + files[k].filename ); |
| 879 | if (registry != 0 && registry->isTag("EntityRegistry")) |
| 880 | { |
| 881 | for (int i = 0; i < registry->getChildCount(); i++) |
| 882 | { |
| 883 | XmlNodeRef child = registry->getChild(i); |
| 884 | if (child->isTag("EntityDesc")) |
| 885 | { |
| 886 | const char *fname = child->getAttr( "File" ); |
| 887 | const char *tableName = child->getAttr( "Name" ); |
| 888 | // Save new format. |
| 889 | fprintf( file,"\t{ \"\",\t\"%s\",\t%.3d,\t\"%s\" },\n",tableName,i+100,fname ); |
| 890 | |
| 891 | |
| 892 | CString file,name; |
no test coverage detected