void CGuiWidget::ParseMessages(CInputStream& in, const CGuiWidgetParms& parms) { s16 count = in.readInt16Big(); assert(count == 0); count = in.readInt16Big(); assert(count == 0); }
void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms) { CGuiWidget* parent = frame->FindWidget(parms.x8_parentId); bool a = in.readBool(); if (a) xf4_workerId = in.readInt16Big(); zeus::CVector3f trans; trans.readBig(in); zeus::CMatrix3f orient; orient.readBig(in); x80_transform = zeus::CTransform(orient, trans); ReapplyXform(); zeus::CVector3f rotCenter; rotCenter.readBig(in); SetRotationCenter(rotCenter); ParseMessages(in, parms); ParseAnimations(in, parms); if (a) if (!parent->AddWorkerWidget(this)) { Log.report(logvisor::Warning, "Warning: Discarding useless worker id. Parent is not a compound widget."); xf4_workerId = -1; } parent->AddChildWidget(this, false, true); }
CInputStream* CResLoader::LoadResourceFromMemorySync(const SObjectTag& tag, const void* buf) { FindResourceForLoad(tag); CInputStream* newStrm = new CMemoryInStream((atUint8*)buf, x50_cachedResInfo->x8_size); if (x50_cachedResInfo->xb_compressed) { newStrm->readUint32Big(); newStrm = new CZipInputStream(std::move(std::unique_ptr<CInputStream>(newStrm))); } return newStrm; }
std::shared_ptr<CGuiWidget> CGuiModel::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) { CGuiWidgetParms parms = ReadWidgetHeader(frame, in); CAssetId model = in.readUint32Big(); in.readUint32Big(); u32 lightMask = in.readUint32Big(); std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiModel>(parms, sp, model, lightMask, true); ret->ParseBaseInfo(frame, in, parms); return ret; }
CAssetId::CAssetId(CInputStream& in) { if (g_Main) { if (g_Main->GetExpectedIdSize() == sizeof(u32)) Assign(in.readUint32Big()); else if (g_Main->GetExpectedIdSize() == sizeof(u64)) Assign(in.readUint64Big()); else Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize()); } else Log.report(logvisor::Fatal, "Input constructor called before runtime Main entered!"); }
CSkinRules::CSkinRules(CInputStream& in) { u32 bankCount = in.readUint32Big(); x0_skinBanks.reserve(bankCount); for (u32 i = 0; i < bankCount; ++i) x0_skinBanks.emplace_back(in); u32 virtualBoneCount = in.readUint32Big(); m_virtualBones.reserve(virtualBoneCount); for (u32 i = 0; i < virtualBoneCount; ++i) m_virtualBones.emplace_back(in); u32 poolSz = in.readUint32Big(); m_poolToSkinIdx.reserve(poolSz); for (u32 i = 0; i < poolSz; ++i) m_poolToSkinIdx.push_back(in.readUint32Big()); }
CInputStream* CResLoader::LoadNewResourceSync(const SObjectTag& tag, void* extBuf) { void* buf = extBuf; CPakFile* file = FindResourceForLoad(tag); size_t resSz = ROUND_UP_32(x50_cachedResInfo->x8_size); if (!buf) { CCallStack cs(AT_PRETTY_FUNCTION, "UnknownType"); buf = CMemory::Alloc(resSz, IAllocator::EHint::Large, IAllocator::EScope::Default, IAllocator::EType::Primitive, cs); } file->SyncSeekRead(buf, resSz, ESeekOrigin::Begin, x50_cachedResInfo->x4_offset); CInputStream* newStrm = new CMemoryInStream((atUint8*)buf, resSz, !extBuf); if (x50_cachedResInfo->xb_compressed) { newStrm->readUint32Big(); newStrm = new CZipInputStream(std::move(std::unique_ptr<CInputStream>(newStrm))); } return newStrm; }
CGuiWidget::CGuiWidgetParms CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag) { std::string name = in.readString(-1); s16 selfId = frame->GetWidgetIdDB().AddWidget(name); std::string parent = in.readString(-1); s16 parentId = frame->GetWidgetIdDB().AddWidget(parent); bool useAnimController = in.readBool(); bool defaultVis = in.readBool(); bool defaultActive = in.readBool(); bool cullFaces = in.readBool(); zeus::CColor color; color.readRGBABig(in); EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big()); return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId, parentId, defaultVis, defaultActive, cullFaces, color, df, true, flag); }
CMetaTransPhaseTrans::CMetaTransPhaseTrans(CInputStream& in) { x4_transDur = CCharAnimTime(in); xc_ = in.readBool(); xd_runA = in.readBool(); x10_flags = in.readUint32Big(); }
CPASParmInfo::CPASParmInfo(CInputStream& in) { xc_min.m_int = 0; x10_max.m_int = 0; x0_type = CPASAnimParm::EParmType(in.readUint32Big()); x4_weightFunction = EWeightFunction(in.readUint32Big()); x8_weight = in.readFloatBig(); switch (x0_type) { case CPASAnimParm::EParmType::Int32: xc_min.m_int = in.readInt32Big(); x10_max.m_int = in.readInt32Big(); break; case CPASAnimParm::EParmType::UInt32: xc_min.m_uint = in.readUint32Big(); x10_max.m_uint = in.readUint32Big(); break; case CPASAnimParm::EParmType::Float: xc_min.m_float = in.readFloatBig(); x10_max.m_float = in.readFloatBig(); break; case CPASAnimParm::EParmType::Bool: xc_min.m_bool = in.readBool(); x10_max.m_bool = in.readBool(); break; case CPASAnimParm::EParmType::Enum: xc_min.m_int = in.readInt32Big(); x10_max.m_int = in.readInt32Big(); break; default: break; } }
void CLevelParser::Load() { CInputStream file; file.open(m_filename); if (!file.is_open()) throw CLevelParserException("Failed to open file: " + m_filename); char lang = CApplication::GetInstancePointer()->GetLanguageChar(); std::string line; int lineNumber = 0; std::set<std::string> translatableLines; while (getline(file, line)) { lineNumber++; boost::replace_all(line, "\t", " "); // replace tab by space // ignore comments std::size_t comment = line.find("//"); if (comment != std::string::npos) line = line.substr(0, comment); boost::algorithm::trim(line); std::size_t pos = line.find_first_of(" \t\n"); std::string command = line.substr(0, pos); if (pos != std::string::npos) { line = line.substr(pos + 1); boost::algorithm::trim(line); } else { line = ""; } if (command.empty()) continue; auto parserLine = MakeUnique<CLevelParserLine>(lineNumber, command); parserLine->SetLevel(this); if (command.length() > 2 && command[command.length() - 2] == '.') { std::string baseCommand = command.substr(0, command.length() - 2); parserLine->SetCommand(baseCommand); char languageChar = command[command.length() - 1]; if (languageChar == 'E' && translatableLines.count(baseCommand) == 0) { translatableLines.insert(baseCommand); } else if (languageChar == lang) { if (translatableLines.count(baseCommand) > 0) { auto it = std::remove_if( m_lines.begin(), m_lines.end(), [&baseCommand](const CLevelParserLineUPtr& line) { return line->GetCommand() == baseCommand; }); m_lines.erase(it, m_lines.end()); } translatableLines.insert(baseCommand); } else { continue; } } while (!line.empty()) { pos = line.find_first_of("="); std::string paramName = line.substr(0, pos); boost::algorithm::trim(paramName); line = line.substr(pos + 1); boost::algorithm::trim(line); if (line[0] == '\"') { pos = line.find_first_of("\"", 1); if (pos == std::string::npos) throw CLevelParserException("Unclosed \" in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber)); } else if (line[0] == '\'') { pos = line.find_first_of("'", 1); if (pos == std::string::npos) throw CLevelParserException("Unclosed ' in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber)); } else { pos = line.find_first_of("="); if (pos != std::string::npos) { std::size_t pos2 = line.find_last_of(" \t\n", line.find_last_not_of(" \t\n", pos-1)); if (pos2 != std::string::npos) pos = pos2; } else { pos = line.length()-1; } } std::string paramValue = line.substr(0, pos + 1); boost::algorithm::trim(paramValue); parserLine->AddParam(paramName, MakeUnique<CLevelParserParam>(paramName, paramValue)); if (pos == std::string::npos) break; line = line.substr(pos + 1); boost::algorithm::trim(line); } if (parserLine->GetCommand().length() > 1 && parserLine->GetCommand()[0] == '#') { std::string cmd = parserLine->GetCommand().substr(1, std::string::npos); if(cmd == "Include") { std::unique_ptr<CLevelParser> includeParser = MakeUnique<CLevelParser>(parserLine->GetParam("file")->AsPath("")); includeParser->Load(); for(CLevelParserLineUPtr& line : includeParser->m_lines) { AddLine(std::move(line)); } } else { throw CLevelParserException("Unknown preprocessor command '#" + cmd + "' (in " + m_filename + ":" + StrUtils::ToString<int>(lineNumber) + ")"); } } else { AddLine(std::move(parserLine)); } } file.close(); }
explicit CVirtualBone(CInputStream& in) { u32 weightCount = in.readUint32Big(); m_weights.reserve(weightCount); for (u32 i = 0; i < weightCount; ++i) m_weights.emplace_back(in); }
explicit SSkinWeighting(CInputStream& in) : m_id(in), m_weight(in.readFloatBig()) {}
CHalfTransition::CHalfTransition(CInputStream& in) { x0_id = in.readUint32Big(); x4_trans = CMetaTransFactory::CreateMetaTrans(in); }
CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {}
CHUDMemoParms(CInputStream& in) { x0_dispTime = in.readFloatBig(); x4_clearMemoWindow = in.readBool(); }
void CScript::New(Ui::CEdit* edit, const char* name) { char res[100]; char text[100]; char script[500]; char buffer[500]; char *sf; int cursor1, cursor2, len, i, j; std::string resStr; GetResource(RES_TEXT, RT_SCRIPT_NEW, resStr); strcpy(res, resStr.c_str()); if ( name[0] == 0 ) strcpy(text, res); else strcpy(text, name); sprintf(script, "extern void object::%s()\n{\n\t\n\t\n\t\n}\n", text); edit->SetText(script, false); if ( strcmp(text, res) == 0 ) { cursor1 = 20; cursor2 = 20+strlen(text); // update "New" } else { if ( edit->GetAutoIndent() ) { cursor1 = 20+strlen(text)+6; cursor2 = cursor1; // cursor in { } } else { cursor1 = 20+strlen(text)+8; cursor2 = cursor1; // cursor in { } } } edit->SetCursor(cursor2, cursor1); edit->ShowSelect(); edit->SetFocus(true); sf = m_main->GetScriptFile(); if ( sf[0] != 0 ) // Load an empty program specific? { std::string filename = sf; CInputStream stream; stream.open(filename); if (stream.is_open()) { len = stream.size(); if ( len > 500-1 ) len = 500-1; stream.read(buffer, len); buffer[len] = 0; stream.close(); cursor1 = 0; i = 0; j = 0; while ( true ) { if ( buffer[i] == 0 ) break; if ( buffer[i] == '\r' ) { i ++; continue; } if ( buffer[i] == '\t' && edit->GetAutoIndent() ) { i ++; continue; } if ( buffer[i+0] == '%' && buffer[i+1] == 's' ) { strcpy(script+j, text); j += strlen(text); i += 2; continue; } if ( buffer[i] == '#' ) { cursor1 = j; i ++; continue; } script[j++] = buffer[i++]; } script[j] = 0; edit->SetText(script, false); cursor2 = cursor1; edit->SetCursor(cursor2, cursor1); edit->ShowSelect(); edit->SetFocus(true); } } ColorizeScript(edit); }