bool CProject::_loadPropMover(const string& filename) { CTextFile file; if (!file.Load(filename)) return false; MoverProp prop; int ID; int i; do { ID = file.GetInt(); prop.name = file.GetString(); prop.AI = (uint)file.GetInt(); for (i = 0; i < 7; i++) file.GetInt(); prop.belligerence = (uint)file.GetInt(); for (i = 0; i < 35; i++) file.NextToken(); prop.fly = file.GetBool(); file.GetLine(); m_moverProps[ID] = prop; } while (file.TokenType() != ETokenType::End); file.Close(); return true; }
bool CProject::_loadModel(const string& filename) { CTextFile file; if (!file.Load(filename)) return false; CFolderElement* folders[32]; CModelElement* model; ModelProp prop; byte type; int max, motion; string motionStr; file.NextToken(); while (file.TokenType() != ETokenType::End) { folders[1] = new CFolderElement(); folders[1]->setIcon(m_icons[1]); folders[1]->setText(file.Token()); m_objFolder->appendRow(folders[1]); type = (byte)file.GetInt(); file.NextToken(); // { file.NextToken(); // nom d'un objet ou } int brace = 1; while (brace) { if (file.TokenType() == ETokenType::EndBlock) { brace--; if (brace > 0) { file.NextToken(); // nom d'un objet ou } continue; } if (brace == 0) continue; } prop.filename = file.Token(); file.SetMark(); file.NextToken(); if (file.TokenType() == ETokenType::StartBlock) { brace++; folders[brace] = new CFolderElement(); folders[brace]->setIcon(m_icons[1]); folders[brace]->setText(prop.filename); folders[brace - 1]->appendRow(folders[brace]); file.NextToken(); // nom d'un objet ou } prop.filename = file.Token(); continue; } else file.GoMark(); prop.ID = file.GetInt(); prop.type = type; prop.modelType = (byte)file.GetInt(); prop.part = file.GetString(); prop.fly = file.GetBool(); prop.distant = (byte)file.GetInt(); prop.pick = file.GetBool(); prop.scale = file.GetFloat(); prop.trans = file.GetBool(); prop.shadow = file.GetBool(); prop.textureEx = (byte)file.GetInt(); prop.renderFlag = file.GetBool(); file.NextToken(); if (file.TokenType() == ETokenType::StartBlock) { file.SetMark(); file.NextToken(); max = 0; while (file.TokenType() != ETokenType::EndBlock) { motion = file.GetInt(); if (motion > max) max = motion; file.NextToken(); // nom d'une animation ou } } max++; prop.motionCount = max; file.GoMark(); file.NextToken(); // nom d'une animation ou } prop.motions = new char[max * 32]; memset(prop.motions, 0, max * 32); while (file.TokenType() != ETokenType::EndBlock) { motionStr = file.Token(); motion = file.GetInt(); file.NextToken(); // nom d'une animation ou } strcpy(prop.GetMotion(motion), motionStr.toLocal8Bit().constData()); } file.NextToken(); // nom d'un objet ou } } else { prop.motionCount = 0; prop.motions = null; } m_models[type][prop.ID] = prop; model = new CModelElement(); model->setIcon(m_icons[3]); if (type == OT_MOVER) { auto it = m_moverProps.constFind(prop.ID); if (it != m_moverProps.constEnd() && !(*it).name.isEmpty()) model->setText((*it).name); else model->setText(prop.filename); } else if (type == OT_ITEM) { auto it = m_itemProps.constFind(prop.ID); if (it != m_itemProps.constEnd() && !(*it).name.isEmpty()) model->setText((*it).name); else model->setText(prop.filename); } else model->setText(prop.filename); model->SetModel(&m_models[type][prop.ID]); folders[brace]->appendRow(model); } file.NextToken(); // type d'objet ou } } file.Close(); return true; }