示例#1
0
文件: main.cpp 项目: AxioDL/hecl
void AthenaExcHandler(athena::error::Level level, const char* file, const char* /*function*/, int line, const char* fmt,
                      ...) {
  static logvisor::Module Log("heclTest::AthenaExcHandler");
  va_list ap;
  va_start(ap, fmt);
  Log.reportSource(logvisor::Level(level), file, uint32_t(line), fmt, ap);
  va_end(ap);
}
示例#2
0
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!");
}
示例#3
0
void CAssetId::PutTo(COutputStream& out) {
  if (g_Main) {
    if (g_Main->GetExpectedIdSize() == sizeof(u32))
      out.writeUint32Big(u32(id));
    else if (g_Main->GetExpectedIdSize() == sizeof(u64))
      out.writeUint64Big(id);
    else
      Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize());
  } else
    Log.report(logvisor::Fatal, "PutTo called before runtime Main entered!");
}
示例#4
0
namespace urde {
logvisor::Module Log("urde::RetroTypes::CAssetId");

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!");
}

void CAssetId::PutTo(COutputStream& out) {
  if (g_Main) {
    if (g_Main->GetExpectedIdSize() == sizeof(u32))
      out.writeUint32Big(u32(id));
    else if (g_Main->GetExpectedIdSize() == sizeof(u64))
      out.writeUint64Big(id);
    else
      Log.report(logvisor::Fatal, "Unsupported id length %i", g_Main->GetExpectedIdSize());
  } else
    Log.report(logvisor::Fatal, "PutTo called before runtime Main entered!");
}

} // namespace urde
示例#5
0
void ColorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct CEKeyframeEmitter);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct CEConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct CETimeChain);
        break;
    case SBIG('CFDE'):
        m_elem.reset(new struct CEFadeEnd);
        break;
    case SBIG('FADE'):
        m_elem.reset(new struct CEFade);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct CEPulse);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ColorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#6
0
void EmitterElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('SETR'):
        m_elem.reset(new struct EESimpleEmitterTR);
        break;
    case SBIG('SEMR'):
        m_elem.reset(new struct EESimpleEmitter);
        break;
    case SBIG('SPHE'):
        m_elem.reset(new struct VESphere);
        break;
    case SBIG('ASPH'):
        m_elem.reset(new struct VEAngleSphere);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#7
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);
}
示例#8
0
void EmitterElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('SETR'):
        m_elem.reset(new struct EESimpleEmitterTR);
        break;
    case SBIG('SEMR'):
        m_elem.reset(new struct EESimpleEmitter);
        break;
    case SBIG('SPHE'):
        m_elem.reset(new struct VESphere);
        break;
    case SBIG('ASPH'):
        m_elem.reset(new struct VEAngleSphere);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown EmitterElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#9
0
void ModVectorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('IMPL'):
        m_elem.reset(new struct MVEImplosion);
        break;
    case SBIG('EMPL'):
        m_elem.reset(new struct MVEExponentialImplosion);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct MVETimeChain);
        break;
    case SBIG('BNCE'):
        m_elem.reset(new struct MVEBounce);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct MVEConstant);
        break;
    case SBIG('GRAV'):
        m_elem.reset(new struct MVEGravity);
        break;
    case SBIG('EXPL'):
        m_elem.reset(new struct MVEExplode);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct MVESetPosition);
        break;
    case SBIG('LMPL'):
        m_elem.reset(new struct MVELinearImplosion);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct MVEPulse);
        break;
    case SBIG('WIND'):
        m_elem.reset(new struct MVEWind);
        break;
    case SBIG('SWRL'):
        m_elem.reset(new struct MVESwirl);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#10
0
Locale::Locale(const std::string& name, const std::string& fullName,
               const unsigned char* yamlSource, size_t yamlLength)
: m_name(name), m_fullName(fullName)
{
    athena::io::YAMLDocReader reader;
    yaml_parser_set_input_string(reader.getParser(), yamlSource, yamlLength);
    reader.parse();
    m_rootNode = std::move(reader.releaseRootNode());
    if (m_rootNode)
    {
        m_langNode = m_rootNode->findMapChild(name.c_str());
        if (!m_langNode)
            Log.report(logvisor::Fatal, "no root node '%s' found in locale", name.c_str());
    }
    else
        Log.report(logvisor::Warning, "locale empty");
}
示例#11
0
文件: main.cpp 项目: KalDragon/urde
static void AthenaExc(athena::error::Level level, const char* file,
                      const char*, int line, const char* fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    AthenaLog.reportSource(logvisor::Level(level), file, line, fmt, ap);
    va_end(ap);
}
示例#12
0
void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
                         const IThemeData* theme, float pf)
{
    if (!factory || !fcache || !theme)
        Log.report(logvisor::Fatal, "all arguments of ViewResources::init() must be non-null");
    m_pixelFactor = pf;
    m_factory = factory;
    m_theme = theme;
    m_fcache = fcache;
    unsigned dpi = 72.f * m_pixelFactor;

    m_curveFont = fcache->prepCurvesFont(factory, AllCharFilter, false, 8.f, dpi);

    m_resData = factory->commitTransaction(
    [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
    {
        switch (ctx.platform())
        {
        case boo::IGraphicsDataFactory::Platform::OGL:
            init<boo::GLDataFactory::Context>(static_cast<boo::GLDataFactory::Context&>(ctx), *theme, fcache);
            break;
#if _WIN32
        case boo::IGraphicsDataFactory::Platform::D3D11:
        case boo::IGraphicsDataFactory::Platform::D3D12:
            init<boo::ID3DDataFactory::Context>(static_cast<boo::ID3DDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
#if BOO_HAS_METAL
        case boo::IGraphicsDataFactory::Platform::Metal:
            init<boo::MetalDataFactory::Context>(static_cast<boo::MetalDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
#if BOO_HAS_VULKAN
        case boo::IGraphicsDataFactory::Platform::Vulkan:
            init<boo::VulkanDataFactory::Context>(static_cast<boo::VulkanDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
        default:
            Log.report(logvisor::Fatal, _S("unable to init view system for %s"), ctx.platformName());
        }
        return true;
    });
}
示例#13
0
文件: main.cpp 项目: KalDragon/urde
    void initialize(boo::IApplication* app)
    {
        zeus::detectCPU();

        const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
        Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
        Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
        hecl::SystemString features;
        if (cpuInf.AESNI)
            features += _S("AES-NI");
        if (cpuInf.SSE1)
        {
            if (!features.empty())
                features += _S(", SSE1");
            else
                features += _S("SSE1");
        }
        else
        {
            Log.report(logvisor::Fatal, _S("URDE requires SSE1 minimum"));
            return;
        }
        if (cpuInf.SSE2)
            features += _S(", SSE2");
        else
        {
            Log.report(logvisor::Fatal, _S("URDE requires SSE2 minimum"));
            return;
        }
        if (cpuInf.SSE3)
            features += _S(", SSE3");
        if (cpuInf.SSSE3)
            features += _S(", SSSE3");
        if (cpuInf.SSE4a)
            features += _S(", SSE4a");
        if (cpuInf.SSE41)
            features += _S(", SSE4.1");
        if (cpuInf.SSE42)
            features += _S(", SSE4.2");
        Log.report(logvisor::Info, _S("CPU Features: %s"), features.c_str());
    }
示例#14
0
文件: icons.cpp 项目: KalDragon/urde
boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes)
{
    athena::io::MemoryReader r(URDE_ICONS, URDE_ICONS_SZ);
    size_t fmt = r.readUint32Big();
    if (fmt != 16)
        Log.report(logvisor::Fatal, "incorrect icon texture format");
    size_t width = r.readUint16Big();
    size_t height = r.readUint16Big();
    size_t mips = r.readUint32Big();
    size_t decompSz = r.readUint32Big();

    std::unique_ptr<uint8_t[]> texels(new uint8_t[decompSz]);
    uLongf destSz = decompSz;
    size_t pos = r.position();
    if (uncompress(texels.get(), &destSz, URDE_ICONS + pos, URDE_ICONS_SZ - pos) != Z_OK)
        Log.report(logvisor::Fatal, "unable to decompress icons");

    g_IconAtlas.initializeAtlas(viewRes.m_factory->newStaticTexture(width, height, mips, boo::TextureFormat::RGBA8,
                                                                    texels.get(), destSz));
    return viewRes.m_factory->commit();
}
示例#15
0
void ModVectorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('IMPL'):
        m_elem.reset(new struct MVEImplosion);
        break;
    case SBIG('EMPL'):
        m_elem.reset(new struct MVEExponentialImplosion);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct MVETimeChain);
        break;
    case SBIG('BNCE'):
        m_elem.reset(new struct MVEBounce);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct MVEConstant);
        break;
    case SBIG('GRAV'):
        m_elem.reset(new struct MVEGravity);
        break;
    case SBIG('EXPL'):
        m_elem.reset(new struct MVEExplode);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct MVESetPosition);
        break;
    case SBIG('LMPL'):
        m_elem.reset(new struct MVELinearImplosion);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct MVEPulse);
        break;
    case SBIG('WIND'):
        m_elem.reset(new struct MVEWind);
        break;
    case SBIG('SWRL'):
        m_elem.reset(new struct MVESwirl);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ModVectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#16
0
void ColorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct CEKeyframeEmitter);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct CEConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct CETimeChain);
        break;
    case SBIG('CFDE'):
        m_elem.reset(new struct CEFadeEnd);
        break;
    case SBIG('FADE'):
        m_elem.reset(new struct CEFade);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct CEPulse);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#17
0
文件: GLX.cpp 项目: AxioDL/boo
namespace boo {
static logvisor::Module Log("boo::GLX");

void GLXExtensionCheck() {
  if (!GLXEW_SGI_video_sync)
    Log.report(logvisor::Fatal, "GLX_SGI_video_sync not available");
  if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control)
    Log.report(logvisor::Fatal, "swap_control not available");
}

void GLXEnableVSync(Display* disp, GLXWindow drawable) {
  if (GLXEW_EXT_swap_control)
    glXSwapIntervalEXT(disp, drawable, 1);
  else if (GLXEW_MESA_swap_control)
    glXSwapIntervalMESA(1);
  else if (GLXEW_SGI_swap_control)
    glXSwapIntervalSGI(1);
}

} // namespace boo
示例#18
0
void IntElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct IEKeyframeEmitter);
        break;
    case SBIG('DETH'):
        m_elem.reset(new struct IEDeath);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct IEClamp);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct IETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct IEAdd);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct IEConstant);
        break;
    case SBIG('IMPL'):
        m_elem.reset(new struct IEImpulse);
        break;
    case SBIG('ILPT'):
        m_elem.reset(new struct IELifetimePercent);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct IEInitialRandom);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct IEPulse);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct IEMultiply);
        break;
    case SBIG('SPAH'):
        m_elem.reset(new struct IESampleAndHold);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct IERandom);
        break;
    case SBIG('TSCL'):
        m_elem.reset(new struct IETimeScale);
        break;
    case SBIG('GTCP'):
        m_elem.reset(new struct IEGTCP);
        break;
    case SBIG('MODU'):
        m_elem.reset(new struct IEModulo);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct IESubtract);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown IntElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#19
0
void RealElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('LFTW'):
        m_elem.reset(new struct RELifetimeTween);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct REConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct RETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct REAdd);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct REClamp);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct REKeyframeEmitter);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct REInitialRandom);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct RERandom);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct REMultiply);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct REPulse);
        break;
    case SBIG('SCAL'):
        m_elem.reset(new struct RETimeScale);
        break;
    case SBIG('RLPT'):
        m_elem.reset(new struct RELifetimePercent);
        break;
    case SBIG('SINE'):
        m_elem.reset(new struct RESineWave);
        break;
    case SBIG('ISWT'):
        m_elem.reset(new struct REInitialSwitch);
        break;
    case SBIG('CLTN'):
        m_elem.reset(new struct RECompareLessThan);
        break;
    case SBIG('CEQL'):
        m_elem.reset(new struct RECompareEquals);
        break;
    case SBIG('PAP1'):
        m_elem.reset(new struct REParticleAdvanceParam1);
        break;
    case SBIG('PAP2'):
        m_elem.reset(new struct REParticleAdvanceParam2);
        break;
    case SBIG('PAP3'):
        m_elem.reset(new struct REParticleAdvanceParam3);
        break;
    case SBIG('PAP4'):
        m_elem.reset(new struct REParticleAdvanceParam4);
        break;
    case SBIG('PAP5'):
        m_elem.reset(new struct REParticleAdvanceParam5);
        break;
    case SBIG('PAP6'):
        m_elem.reset(new struct REParticleAdvanceParam6);
        break;
    case SBIG('PAP7'):
        m_elem.reset(new struct REParticleAdvanceParam7);
        break;
    case SBIG('PAP8'):
        m_elem.reset(new struct REParticleAdvanceParam8);
        break;
    case SBIG('PSLL'):
        m_elem.reset(new struct REParticleSizeOrLineLength);
        break;
    case SBIG('PRLW'):
        m_elem.reset(new struct REParticleRotationOrLineWidth);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct RESubtract);
        break;
    case SBIG('VMAG'):
        m_elem.reset(new struct REVectorMagnitude);
        break;
    case SBIG('VXTR'):
        m_elem.reset(new struct REVectorXToReal);
        break;
    case SBIG('VYTR'):
        m_elem.reset(new struct REVectorYToReal);
        break;
    case SBIG('VZTR'):
        m_elem.reset(new struct REVectorZToReal);
        break;
    case SBIG('CEXT'):
        m_elem.reset(new struct RECEXT);
        break;
    case SBIG('ITRL'):
        m_elem.reset(new struct REIntTimesReal);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#20
0
文件: GLX.cpp 项目: AxioDL/boo
void GLXExtensionCheck() {
  if (!GLXEW_SGI_video_sync)
    Log.report(logvisor::Fatal, "GLX_SGI_video_sync not available");
  if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control)
    Log.report(logvisor::Fatal, "swap_control not available");
}
示例#21
0
void VectorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('CONE'):
        m_elem.reset(new struct VECone);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct VETimeChain);
        break;
    case SBIG('ANGC'):
        m_elem.reset(new struct VEAngleCone);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct VEAdd);
        break;
    case SBIG('CCLU'):
        m_elem.reset(new struct VECircleCluster);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct VEConstant);
        break;
    case SBIG('CIRC'):
        m_elem.reset(new struct VECircle);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct VEKeyframeEmitter);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct VEMultiply);
        break;
    case SBIG('RTOV'):
        m_elem.reset(new struct VERealToVector);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct VEPulse);
        break;
    case SBIG('PVEL'):
        m_elem.reset(new struct VEParticleVelocity);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct VESPOS);
        break;
    case SBIG('PLCO'):
        m_elem.reset(new struct VEPLCO);
        break;
    case SBIG('PLOC'):
        m_elem.reset(new struct VEPLOC);
        break;
    case SBIG('PSOR'):
        m_elem.reset(new struct VEPSOR);
        break;
    case SBIG('PSOF'):
        m_elem.reset(new struct VEPSOF);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown VectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#22
0
namespace urde
{
static logvisor::Module Log("urde::CGuiWidget");

typedef bool(CGuiWidget::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info);
static std::unordered_map<u32, FMAF> WidgetFnMap;

void CGuiWidget::LoadWidgetFnMap()
{
    WidgetFnMap.emplace(std::make_pair(2, &CGuiWidget::MAF_StartAnimationSet));
    WidgetFnMap.emplace(std::make_pair(3, &CGuiWidget::MAF_SendMessage));
    WidgetFnMap.emplace(std::make_pair(6, &CGuiWidget::MAF_PauseAnim));
    WidgetFnMap.emplace(std::make_pair(7, &CGuiWidget::MAF_ResumeAnim));
    WidgetFnMap.emplace(std::make_pair(11, &CGuiWidget::MAF_SetState));
    WidgetFnMap.emplace(std::make_pair(12, &CGuiWidget::MAF_SetStateOfWidget));
}

CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
: x7c_selfId(parms.x6_selfId), x7e_parentId(parms.x8_parentId),
  xbc_color(parms.x10_color), xc0_color2(parms.x10_color),
  xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame),
  xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible),
  xf6_26_isActive(parms.xb_defaultActive),
  xf6_27_(true), xf6_28_eventLock(false),
  xf6_29_cullFaces(parms.xc_cullFaces), xf6_30_(false),
  xf6_31_(true), xf7_24_(false), xf7_25_(true)
{
    if (parms.x4_useAnimController)
        EnsureHasAnimController();
    RecalcWidgetColor(ETraversalMode::Single);
}

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);
}

CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
    CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
    CGuiWidget* ret = new CGuiWidget(parms);
    ret->ParseBaseInfo(frame, in, parms);
    return ret;
}

bool CGuiWidget::Message(const CGuiMessage& msg)
{
}

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);
}

void CGuiWidget::ParseMessages(CInputStream& in, const CGuiWidgetParms& parms)
{
    s16 count = in.readInt16Big();
    assert(count == 0);
    count = in.readInt16Big();
    assert(count == 0);
}

void CGuiWidget::ParseAnimations(CInputStream& in, const CGuiWidgetParms& parms)
{
    s16 count = in.readInt16Big();
    assert(count == 0);
}

std::vector<TResId> CGuiWidget::GetTextureAssets() const
{
    return {};
}

std::vector<TResId> CGuiWidget::GetModelAssets() const
{
    return {};
}

std::vector<TResId> CGuiWidget::GetFontAssets() const
{
    return {};
}

void CGuiWidget::Initialize() {}
void CGuiWidget::Touch() const {}

bool CGuiWidget::GetIsVisible() const
{
    return xf6_25_isVisible;
}

bool CGuiWidget::GetIsActive() const
{
    return xf6_26_isActive;
}

CGuiTextSupport* CGuiWidget::TextSupport()
{
    return nullptr;
}

CGuiTextSupport* CGuiWidget::GetTextSupport() const
{
    return nullptr;
}

void CGuiWidget::ModifyRGBA(CGuiWidget* widget)
{
    xb8_ += widget->xb8_;
    xb4_ = xb8_ + xc0_color2;
}

void CGuiWidget::RecalculateAllRGBA()
{
    CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
    if (parent)
        ModifyRGBA(parent);
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->RecalculateAllRGBA();
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->RecalculateAllRGBA();
}

void CGuiWidget::InitializeRGBAFactor()
{
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->InitializeRGBAFactor();
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->InitializeRGBAFactor();
}

bool CGuiWidget::GetIsFinishedLoadingWidgetSpecific() const
{
    return true;
}

std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* CGuiWidget::FindTriggerList(int id)
{
    auto search = xcc_triggerMap.find(id);
    if (search == xcc_triggerMap.cend())
        return nullptr;
    return search->second.get();
}

void CGuiWidget::AddTrigger(std::unique_ptr<CGuiLogicalEventTrigger>&& trigger)
{
    int tid = trigger->GetTriggerId();
    std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* list = FindTriggerList(tid);
    if (!list)
    {
        auto it =
        xcc_triggerMap.emplace(std::make_pair(tid,
            std::make_unique<std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>>()));
        list = it.first->second.get();
    }
    list->push_back(std::move(trigger));
}

std::vector<std::unique_ptr<CGuiFunctionDef>>* CGuiWidget::FindFunctionDefList(int id)
{
    auto search = xe0_functionMap.find(id);
    if (search == xe0_functionMap.cend())
        return nullptr;
    return search->second.get();
}

void CGuiWidget::AddFunctionDef(s32 id, std::unique_ptr<CGuiFunctionDef>&& def)
{
    std::vector<std::unique_ptr<CGuiFunctionDef>>* list = FindFunctionDefList(id);
    if (!list)
    {
        auto it =
        xe0_functionMap.emplace(std::make_pair(id,
            std::make_unique<std::vector<std::unique_ptr<CGuiFunctionDef>>>()));
        list = it.first->second.get();
    }
    list->push_back(std::move(def));
}

void CGuiWidget::SetIdlePosition(const zeus::CVector3f& pos, bool reapply)
{
    x80_transform.m_origin = pos;
    if (reapply)
        ReapplyXform();
}

void CGuiWidget::ReapplyXform()
{
    RotateReset();
    SetLocalPosition(zeus::CVector3f::skZero);
    MultiplyO2P(x80_transform);
}

void CGuiWidget::EnsureHasAnimController()
{
    if (!xb0_animController)
    {
        xb0_animController.reset(new CGuiAnimController(
            CGuiWidgetParms(xc8_frame, false, -1, -1, true, false, false,
                            zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha,
                            true, false), this));
    }
}

void CGuiWidget::BroadcastMessage(int id, CGuiControllerInfo* info)
{
    CGuiFuncParm a((intptr_t(x7c_selfId)));
    CGuiFuncParm b((intptr_t(id)));
    CGuiFunctionDef def(0, false, a, b);
    MAF_SendMessage(&def, info);

    CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
    if (ch)
        ch->BroadcastMessage(id, info);

    CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
    if (sib)
        sib->BroadcastMessage(id, info);
}

void CGuiWidget::LockEvents(bool lock)
{
    xf6_28_eventLock = lock;
    if (lock)
        DoUnregisterEventHandler();
    else
        DoRegisterEventHandler();
}

void CGuiWidget::UnregisterEventHandler()
{
    bool flag = DoUnregisterEventHandler();
    if (!flag)
    {
        CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
        if (ch)
            ch->UnregisterEventHandler();
    }
    CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
    if (sib && flag)
        sib->UnregisterEventHandler();
}

void CGuiWidget::UnregisterEventHandler(ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
        if (!DoUnregisterEventHandler())
        {
            CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
            if (ch)
                ch->UnregisterEventHandler();
        }
        break;
    case ETraversalMode::Single:
        DoUnregisterEventHandler();
        break;
    default:
        UnregisterEventHandler();
        break;
    }
}

bool CGuiWidget::DoUnregisterEventHandler()
{
    for (auto& item : xcc_triggerMap)
        for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
            xc8_frame->ClearMessageMap(trigger.get(), x7c_selfId);
    return false;
}

void CGuiWidget::RegisterEventHandler()
{
    bool flag = DoRegisterEventHandler();
    if (!flag)
    {
        CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
        if (ch)
            ch->RegisterEventHandler();
    }
    CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
    if (sib && flag)
        sib->RegisterEventHandler();
}

void CGuiWidget::RegisterEventHandler(ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
        if (!DoRegisterEventHandler())
        {
            CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
            if (ch)
                ch->RegisterEventHandler();
        }
        break;
    case ETraversalMode::Single:
        DoRegisterEventHandler();
        break;
    default:
        RegisterEventHandler();
        break;
    }
}

bool CGuiWidget::DoRegisterEventHandler()
{
    if (xf6_28_eventLock || !GetIsActive())
        return false;
    for (auto& item : xcc_triggerMap)
        for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
            xc8_frame->AddMessageMap(trigger.get(), x7c_selfId);
    return false;
}

CGuiWidget* CGuiWidget::RemoveChildWidget(CGuiWidget* widget, bool makeWorldLocal)
{
    return static_cast<CGuiWidget*>(RemoveChildObject(widget, makeWorldLocal));
}

void CGuiWidget::AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd)
{
    AddChildObject(widget, makeWorldLocal, atEnd);
}

bool CGuiWidget::AddWorkerWidget(CGuiWidget* worker)
{
    return false;
}

void CGuiWidget::AddAnim(EGuiAnimBehListID id, CGuiAnimBase* anim)
{
    if (!xb0_animController)
    {
        xb0_animController.reset(new CGuiAnimController(
            CGuiWidgetParms(xc8_frame, false, -1, -1, false, false, false,
                            zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha, true, false), this));
    }
    xb0_animController->AddAnimation(anim, id);
}

void CGuiWidget::ResetAllAnimUpdateState()
{
    if (xb0_animController)
        xb0_animController->ResetListUpdateState();
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->ResetAllAnimUpdateState();
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->ResetAllAnimUpdateState();
}

void CGuiWidget::SetVisibility(bool vis, ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
    {
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
        break;
    }
    case ETraversalMode::ChildrenAndSiblings:
    {
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
        CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
        if (nextSib)
            nextSib->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
        break;
    }
    default: break;
    }
    SetIsVisible(vis);
}

void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state)
{
    if (xb0_animController)
        xb0_animController->SetListUpdateState(id, state);
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->SetAnimUpdateState(id, state);
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->SetAnimUpdateState(id, state);
}

void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state, ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
    {
        if (xb0_animController)
            xb0_animController->SetListUpdateState(id, state);
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->SetAnimUpdateState(id, state);
        break;
    }
    case ETraversalMode::Single:
    {
        if (xb0_animController)
            xb0_animController->SetListUpdateState(id, state);
        break;
    }
    default:
        SetAnimUpdateState(id, state);
        break;
    }
}

void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len)
{
    if (xb0_animController)
    {
        float aLen = xb0_animController->GetAnimSetLength(id);
        if (aLen > len)
            len = aLen;
    }
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->GetBranchAnimLen(id, len);
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->GetBranchAnimLen(id, len);
}

void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len, ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
    {
        if (xb0_animController)
        {
            float aLen = xb0_animController->GetAnimSetLength(id);
            if (aLen > len)
                len = aLen;
        }
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->GetBranchAnimLen(id, len);
        break;
    }
    case ETraversalMode::Single:
    {
        if (xb0_animController)
        {
            float aLen = xb0_animController->GetAnimSetLength(id);
            if (aLen > len)
                len = aLen;
        }
        break;
    }
    default:
        GetBranchAnimLen(id, len);
        break;
    }
}

void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone)
{
    if (xb0_animController)
    {
        if (!isDone)
            return;
        xb0_animController->IsAnimsDone(id, isDone);
    }
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->IsAllAnimsDone(id, isDone);
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->IsAllAnimsDone(id, isDone);
}

void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone, ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
    {
        if (xb0_animController)
        {
            xb0_animController->IsAnimsDone(id, isDone);
            if (!isDone)
                return;
        }
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->IsAllAnimsDone(id, isDone);
        break;
    }
    case ETraversalMode::Single:
    {
        if (xb0_animController)
            xb0_animController->IsAnimsDone(id, isDone);
        break;
    }
    default:
        IsAllAnimsDone(id, isDone);
        break;
    }
}

void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
                                           EGuiAnimInitMode initMode)
{
    if (xb0_animController)
        xb0_animController->InitTransform(this, id, fval, flag, initMode);
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
        child->InitializeAnimControllers(id, fval, flag, initMode);
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
        nextSib->InitializeAnimControllers(id, fval, flag, initMode);
}

void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
                                           EGuiAnimInitMode initMode, ETraversalMode mode)
{
    switch (mode)
    {
    case ETraversalMode::Children:
    {
        if (xb0_animController)
            xb0_animController->InitTransform(this, id, fval, flag, initMode);
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->InitializeAnimControllers(id, fval, flag, initMode);
        break;
    }
    case ETraversalMode::Single:
    {
        if (xb0_animController)
            xb0_animController->InitTransform(this, id, fval, flag, initMode);
        break;
    }
    default:
        InitializeAnimControllers(id, fval, flag, initMode);
        break;
    }
}

void CGuiWidget::RecalcWidgetColor(ETraversalMode mode)
{
    CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
    if (parent)
        xc0_color2 = xbc_color * parent->xc0_color2;
    else
        xc0_color2 = xbc_color;
    xb4_ = xb8_ + xc0_color2;

    switch (mode)
    {
    case ETraversalMode::ChildrenAndSiblings:
    {
        CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
        if (nextSib)
            nextSib->RecalcWidgetColor(ETraversalMode::ChildrenAndSiblings);
    }
    case ETraversalMode::Children:
    {
        CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
        if (child)
            child->RecalcWidgetColor(ETraversalMode::ChildrenAndSiblings);
    }
    default: break;
    }
}

CGuiWidget* CGuiWidget::FindWidget(s16 id)
{
    if (x7c_selfId == id)
        return this;
    CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
    if (child)
    {
        CGuiWidget* found = child->FindWidget(id);
        if (found)
            return found;
    }
    CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
    if (nextSib)
    {
        CGuiWidget* found = nextSib->FindWidget(id);
        if (found)
            return found;
    }
    return nullptr;
}

bool CGuiWidget::GetIsFinishedLoading() const
{
    bool widgetFinished = GetIsFinishedLoadingWidgetSpecific();
    if (!xb0_animController)
        return widgetFinished;
    return widgetFinished && xb0_animController->GetIsFinishedLoading();
}

void CGuiWidget::InitializeRecursive()
{
    Initialize();
    CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
    if (ch)
        ch->InitializeRecursive();
    CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
    if (sib)
        sib->InitializeRecursive();
}

void CGuiWidget::SetColor(const zeus::CColor& color)
{
    xbc_color = color;
    RecalcWidgetColor(ETraversalMode::Children);
}

void CGuiWidget::OnDeActivate() {}
void CGuiWidget::OnActivate(bool) {}
void CGuiWidget::OnInvisible() {}
void CGuiWidget::OnVisible() {}

void CGuiWidget::SetIsVisible(bool vis)
{
    xf6_25_isVisible = vis;
    if (vis)
        OnVisible();
    else
        OnInvisible();
}

void CGuiWidget::SetIsActive(bool a, bool b)
{
    if (a == xf6_26_isActive)
        return;
    xf6_26_isActive = a;
    if (a)
    {
        RegisterEventHandler(ETraversalMode::Children);
        OnActivate(b);
    }
    else
    {
        RegisterEventHandler(ETraversalMode::Children);
        OnDeActivate();
    }
}

bool CGuiWidget::MAF_StartAnimationSet(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

bool CGuiWidget::MAF_SendMessage(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

bool CGuiWidget::MAF_PauseAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

bool CGuiWidget::MAF_ResumeAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

bool CGuiWidget::MAF_SetState(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

bool CGuiWidget::MAF_SetStateOfWidget(CGuiFunctionDef* def, CGuiControllerInfo* info)
{
}

}
示例#23
0
void VectorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('CONE'):
        m_elem.reset(new struct VECone);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct VETimeChain);
        break;
    case SBIG('ANGC'):
        m_elem.reset(new struct VEAngleCone);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct VEAdd);
        break;
    case SBIG('CCLU'):
        m_elem.reset(new struct VECircleCluster);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct VEConstant);
        break;
    case SBIG('CIRC'):
        m_elem.reset(new struct VECircle);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct VEKeyframeEmitter);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct VEMultiply);
        break;
    case SBIG('RTOV'):
        m_elem.reset(new struct VERealToVector);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct VEPulse);
        break;
    case SBIG('PVEL'):
        m_elem.reset(new struct VEParticleVelocity);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct VESPOS);
        break;
    case SBIG('PLCO'):
        m_elem.reset(new struct VEPLCO);
        break;
    case SBIG('PLOC'):
        m_elem.reset(new struct VEPLOC);
        break;
    case SBIG('PSOR'):
        m_elem.reset(new struct VEPSOR);
        break;
    case SBIG('PSOF'):
        m_elem.reset(new struct VEPSOF);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#24
0
int main(int argc, const boo::SystemChar** argv)
#endif
{
  logvisor::RegisterConsoleLogger();

  std::vector<boo::SystemString> m_args;
  m_args.reserve(argc);
  double rate = NativeSampleRate;
  int chCount = 2;
  double volume = 1.0;
  for (int i = 1; i < argc; ++i) {
#if _WIN32
    if (!wcsncmp(argv[i], L"-r", 2)) {
      if (argv[i][2])
        rate = wcstod(&argv[i][2], nullptr);
      else if (argc > (i + 1)) {
        rate = wcstod(argv[i + 1], nullptr);
        ++i;
      }
    } else if (!wcsncmp(argv[i], L"-c", 2)) {
      if (argv[i][2])
        chCount = wcstoul(&argv[i][2], nullptr, 0);
      else if (argc > (i + 1)) {
        chCount = wcstoul(argv[i + 1], nullptr, 0);
        ++i;
      }
    } else if (!wcsncmp(argv[i], L"-v", 2)) {
      if (argv[i][2])
        volume = wcstod(&argv[i][2], nullptr);
      else if (argc > (i + 1)) {
        volume = wcstod(argv[i + 1], nullptr);
        ++i;
      }
    } else
      m_args.push_back(argv[i]);
#else
    if (!strncmp(argv[i], "-r", 2)) {
      if (argv[i][2])
        rate = strtod(&argv[i][2], nullptr);
      else if (argc > (i + 1)) {
        rate = strtod(argv[i + 1], nullptr);
        ++i;
      }
    } else if (!strncmp(argv[i], "-c", 2)) {
      if (argv[i][2])
        chCount = strtoul(&argv[i][2], nullptr, 0);
      else if (argc > (i + 1)) {
        chCount = strtoul(argv[i + 1], nullptr, 0);
        ++i;
      }
    } else if (!strncmp(argv[i], "-v", 2)) {
      if (argv[i][2])
        volume = strtod(&argv[i][2], nullptr);
      else if (argc > (i + 1)) {
        volume = strtod(argv[i + 1], nullptr);
        ++i;
      }
    } else
      m_args.push_back(argv[i]);
#endif
  }

  /* Load data */
  if (m_args.size() < 1) {
    Log.report(logvisor::Error,
               "Usage: amuserender <group-file> [<songs-file>] [-r <sample-rate>] [-c <channel-count>] [-v <volume "
               "0.0-1.0>]");
    return 1;
  }

  amuse::ContainerRegistry::Type cType = amuse::ContainerRegistry::DetectContainerType(m_args[0].c_str());
  if (cType == amuse::ContainerRegistry::Type::Invalid) {
    Log.report(logvisor::Error, "invalid/no data at path argument");
    return 1;
  }
  Log.report(logvisor::Info, _SYS_STR("Found '%s' Audio Group data"), amuse::ContainerRegistry::TypeToName(cType));

  std::vector<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>> data =
      amuse::ContainerRegistry::LoadContainer(m_args[0].c_str());
  if (data.empty()) {
    Log.report(logvisor::Error, "invalid/no data at path argument");
    return 1;
  }

  int m_groupId = -1;
  int m_setupId = -1;
  const amuse::SystemString* m_groupName = nullptr;
  const amuse::SystemString* m_songName = nullptr;
  amuse::ContainerRegistry::SongData* m_arrData = nullptr;
  bool m_sfxGroup = false;

  std::list<amuse::AudioGroupProject> m_projs;
  std::map<int, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
                          amuse::ObjToken<amuse::SongGroupIndex>>>
      allSongGroups;
  std::map<int, std::pair<std::pair<amuse::SystemString, amuse::IntrusiveAudioGroupData>*,
                          amuse::ObjToken<amuse::SFXGroupIndex>>>
      allSFXGroups;
  size_t totalGroups = 0;

  for (auto& grp : data) {
    /* Load project to assemble group list */
    m_projs.push_back(amuse::AudioGroupProject::CreateAudioGroupProject(grp.second));
    amuse::AudioGroupProject& proj = m_projs.back();
    totalGroups += proj.sfxGroups().size() + proj.songGroups().size();

    for (auto it = proj.songGroups().begin(); it != proj.songGroups().end(); ++it)
      allSongGroups[it->first] = std::make_pair(&grp, it->second);

    for (auto it = proj.sfxGroups().begin(); it != proj.sfxGroups().end(); ++it)
      allSFXGroups[it->first] = std::make_pair(&grp, it->second);
  }

  /* Attempt loading song */
  std::vector<std::pair<amuse::SystemString, amuse::ContainerRegistry::SongData>> songs;
  if (m_args.size() > 1)
    songs = amuse::ContainerRegistry::LoadSongs(m_args[1].c_str());
  else
    songs = amuse::ContainerRegistry::LoadSongs(m_args[0].c_str());

  if (songs.size()) {
    bool play = true;
    if (m_args.size() <= 1) {
      bool prompt = true;
      while (true) {
        if (prompt) {
          printf("Render Song? (Y/N): ");
          prompt = false;
        }
        char userSel;
        if (scanf("%c", &userSel) <= 0 || userSel == '\n')
          continue;
        userSel = tolower(userSel);
        if (userSel == 'n')
          play = false;
        else if (userSel != 'y') {
          prompt = true;
          continue;
        }
        break;
      }
    }

    if (play) {
      /* Get song selection from user */
      if (songs.size() > 1) {
        /* Ask user to specify which song */
        printf("Multiple Songs discovered:\n");
        int idx = 0;
        for (const auto& pair : songs) {
          const amuse::ContainerRegistry::SongData& sngData = pair.second;
          int16_t grpId = sngData.m_groupId;
          int16_t setupId = sngData.m_setupId;
          if (sngData.m_groupId == -1 && sngData.m_setupId != -1) {
            for (const auto& pair : allSongGroups) {
              for (const auto& setup : pair.second.second->m_midiSetups) {
                if (setup.first == sngData.m_setupId) {
                  grpId = pair.first;
                  break;
                }
              }
              if (grpId != -1)
                break;
            }
          }
          amuse::Printf(_SYS_STR("    %d %s (Group %d, Setup %d)\n"), idx++, pair.first.c_str(), grpId, setupId);
        }

        int userSel = 0;
        printf("Enter Song Number: ");
        if (scanf("%d", &userSel) <= 0) {
          Log.report(logvisor::Error, "unable to parse prompt");
          return 1;
        }

        if (userSel < songs.size()) {
          m_arrData = &songs[userSel].second;
          m_groupId = m_arrData->m_groupId;
          m_setupId = m_arrData->m_setupId;
          m_songName = &songs[userSel].first;
        } else {
          Log.report(logvisor::Error, "unable to find Song %d", userSel);
          return 1;
        }
      } else if (songs.size() == 1) {
        m_arrData = &songs[0].second;
        m_groupId = m_arrData->m_groupId;
        m_setupId = m_arrData->m_setupId;
        m_songName = &songs[0].first;
      }
    }
  }

  /* Get group selection via setup search */
  if (m_groupId == -1 && m_setupId != -1) {
    for (const auto& pair : allSongGroups) {
      for (const auto& setup : pair.second.second->m_midiSetups) {
        if (setup.first == m_setupId) {
          m_groupId = pair.first;
          m_groupName = &pair.second.first->first;
          break;
        }
      }
      if (m_groupId != -1)
        break;
    }
  }

  /* Get group selection via user */
  if (m_groupId != -1) {
    auto songSearch = allSongGroups.find(m_groupId);
    auto sfxSearch = allSFXGroups.find(m_groupId);
    if (songSearch != allSongGroups.end()) {
      m_sfxGroup = false;
      m_groupName = &songSearch->second.first->first;
    } else if (sfxSearch != allSFXGroups.end()) {
      m_sfxGroup = true;
      m_groupName = &sfxSearch->second.first->first;
    } else {
      Log.report(logvisor::Error, "unable to find Group %d", m_groupId);
      return 1;
    }
  } else if (totalGroups > 1) {
    /* Ask user to specify which group in project */
    printf("Multiple Audio Groups discovered:\n");
    for (const auto& pair : allSFXGroups) {
      amuse::Printf(_SYS_STR("    %d %s (SFXGroup)  %" PRISize " sfx-entries\n"), pair.first,
                    pair.second.first->first.c_str(), pair.second.second->m_sfxEntries.size());
    }
    for (const auto& pair : allSongGroups) {
      amuse::Printf(_SYS_STR("    %d %s (SongGroup)  %" PRISize " normal-pages, %" PRISize " drum-pages, %" PRISize
                             " MIDI-setups\n"),
                    pair.first, pair.second.first->first.c_str(), pair.second.second->m_normPages.size(),
                    pair.second.second->m_drumPages.size(), pair.second.second->m_midiSetups.size());
    }

    int userSel = 0;
    printf("Enter Group Number: ");
    if (scanf("%d", &userSel) <= 0) {
      Log.report(logvisor::Error, "unable to parse prompt");
      return 1;
    }

    auto songSearch = allSongGroups.find(userSel);
    auto sfxSearch = allSFXGroups.find(userSel);
    if (songSearch != allSongGroups.end()) {
      m_groupId = userSel;
      m_groupName = &songSearch->second.first->first;
      m_sfxGroup = false;
    } else if (sfxSearch != allSFXGroups.end()) {
      m_groupId = userSel;
      m_groupName = &sfxSearch->second.first->first;
      m_sfxGroup = true;
    } else {
      Log.report(logvisor::Error, "unable to find Group %d", userSel);
      return 1;
    }
  } else if (totalGroups == 1) {
    /* Load one and only group */
    if (allSongGroups.size()) {
      const auto& pair = *allSongGroups.cbegin();
      m_groupId = pair.first;
      m_groupName = &pair.second.first->first;
      m_sfxGroup = false;
    } else {
      const auto& pair = *allSFXGroups.cbegin();
      m_groupId = pair.first;
      m_groupName = &pair.second.first->first;
      m_sfxGroup = true;
    }
  } else {
    Log.report(logvisor::Error, "empty project");
    return 1;
  }

  /* Make final group selection */
  amuse::IntrusiveAudioGroupData* selData = nullptr;
  amuse::ObjToken<amuse::SongGroupIndex> songIndex;
  amuse::ObjToken<amuse::SFXGroupIndex> sfxIndex;
  auto songSearch = allSongGroups.find(m_groupId);
  if (songSearch != allSongGroups.end()) {
    selData = &songSearch->second.first->second;
    songIndex = songSearch->second.second;
    std::set<int> sortSetups;
    for (auto& pair : songIndex->m_midiSetups)
      sortSetups.insert(pair.first);
    if (m_setupId == -1) {
      /* Ask user to specify which group in project */
      printf("Multiple MIDI Setups:\n");
      for (int setup : sortSetups)
        printf("    %d\n", setup);
      int userSel = 0;
      printf("Enter Setup Number: ");
      if (scanf("%d", &userSel) <= 0) {
        Log.report(logvisor::Error, "unable to parse prompt");
        return 1;
      }
      m_setupId = userSel;
    }
    if (sortSetups.find(m_setupId) == sortSetups.cend()) {
      Log.report(logvisor::Error, "unable to find setup %d", m_setupId);
      return 1;
    }
  } else {
    auto sfxSearch = allSFXGroups.find(m_groupId);
    if (sfxSearch != allSFXGroups.end()) {
      selData = &sfxSearch->second.first->second;
      sfxIndex = sfxSearch->second.second;
    }
  }

  if (!selData) {
    Log.report(logvisor::Error, "unable to select audio group data");
    return 1;
  }

  if (m_sfxGroup) {
    Log.report(logvisor::Error, "amuserender is currently only able to render SongGroups");
    return 1;
  }

  /* WAV out path */
  amuse::SystemChar pathOut[1024];
  SNPrintf(pathOut, 1024, _SYS_STR("%s-%s.wav"), m_groupName->c_str(), m_songName->c_str());
  Log.report(logvisor::Info, _SYS_STR("Writing to %s"), pathOut);

  /* Build voice engine */
  std::unique_ptr<boo::IAudioVoiceEngine> voxEngine = boo::NewWAVAudioVoiceEngine(pathOut, rate, chCount);
  amuse::BooBackendVoiceAllocator booBackend(*voxEngine);
  amuse::Engine engine(booBackend, amuse::AmplitudeMode::PerSample);
  engine.setVolume(float(amuse::clamp(0.0, volume, 1.0)));

  /* Load group into engine */
  const amuse::AudioGroup* group = engine.addAudioGroup(*selData);
  if (!group) {
    Log.report(logvisor::Error, "unable to add audio group");
    return 1;
  }

  /* Enter playback loop */
  amuse::ObjToken<amuse::Sequencer> seq = engine.seqPlay(m_groupId, m_setupId, m_arrData->m_data.get(), false);
  size_t wroteFrames = 0;
  signal(SIGINT, SIGINTHandler);
  do {
    voxEngine->pumpAndMixVoices();
    wroteFrames += voxEngine->get5MsFrames();
    printf("\rFrame %" PRISize, wroteFrames);
    fflush(stdout);
  } while (!g_BreakLoop && (seq->state() == amuse::SequencerState::Playing || seq->getVoiceCount() != 0));

  printf("\n");
  return 0;
}
示例#25
0
void IntElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct IEKeyframeEmitter);
        break;
    case SBIG('DETH'):
        m_elem.reset(new struct IEDeath);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct IEClamp);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct IETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct IEAdd);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct IEConstant);
        break;
    case SBIG('IMPL'):
        m_elem.reset(new struct IEImpulse);
        break;
    case SBIG('ILPT'):
        m_elem.reset(new struct IELifetimePercent);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct IEInitialRandom);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct IEPulse);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct IEMultiply);
        break;
    case SBIG('SPAH'):
        m_elem.reset(new struct IESampleAndHold);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct IERandom);
        break;
    case SBIG('TSCL'):
        m_elem.reset(new struct IETimeScale);
        break;
    case SBIG('GTCP'):
        m_elem.reset(new struct IEGTCP);
        break;
    case SBIG('MODU'):
        m_elem.reset(new struct IEModulo);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct IESubtract);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}
示例#26
0
void RealElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('LFTW'):
        m_elem.reset(new struct RELifetimeTween);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct REConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct RETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct REAdd);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct REClamp);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct REKeyframeEmitter);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct REInitialRandom);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct RERandom);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct REMultiply);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct REPulse);
        break;
    case SBIG('SCAL'):
        m_elem.reset(new struct RETimeScale);
        break;
    case SBIG('RLPT'):
        m_elem.reset(new struct RELifetimePercent);
        break;
    case SBIG('SINE'):
        m_elem.reset(new struct RESineWave);
        break;
    case SBIG('ISWT'):
        m_elem.reset(new struct REInitialSwitch);
        break;
    case SBIG('CLTN'):
        m_elem.reset(new struct RECompareLessThan);
        break;
    case SBIG('CEQL'):
        m_elem.reset(new struct RECompareEquals);
        break;
    case SBIG('PAP1'):
        m_elem.reset(new struct REParticleAdvanceParam1);
        break;
    case SBIG('PAP2'):
        m_elem.reset(new struct REParticleAdvanceParam2);
        break;
    case SBIG('PAP3'):
        m_elem.reset(new struct REParticleAdvanceParam3);
        break;
    case SBIG('PAP4'):
        m_elem.reset(new struct REParticleAdvanceParam4);
        break;
    case SBIG('PAP5'):
        m_elem.reset(new struct REParticleAdvanceParam5);
        break;
    case SBIG('PAP6'):
        m_elem.reset(new struct REParticleAdvanceParam6);
        break;
    case SBIG('PAP7'):
        m_elem.reset(new struct REParticleAdvanceParam7);
        break;
    case SBIG('PAP8'):
        m_elem.reset(new struct REParticleAdvanceParam8);
        break;
    case SBIG('PSLL'):
        m_elem.reset(new struct REParticleSizeOrLineLength);
        break;
    case SBIG('PRLW'):
        m_elem.reset(new struct REParticleRotationOrLineWidth);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct RESubtract);
        break;
    case SBIG('VMAG'):
        m_elem.reset(new struct REVectorMagnitude);
        break;
    case SBIG('VXTR'):
        m_elem.reset(new struct REVectorXToReal);
        break;
    case SBIG('VYTR'):
        m_elem.reset(new struct REVectorYToReal);
        break;
    case SBIG('VZTR'):
        m_elem.reset(new struct REVectorZToReal);
        break;
    case SBIG('CEXT'):
        m_elem.reset(new struct RECEXT);
        break;
    case SBIG('ITRL'):
        m_elem.reset(new struct REIntTimesReal);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown RealElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}
示例#27
0
文件: icons.cpp 项目: KalDragon/urde
namespace urde
{
static logvisor::Module Log("URDE::icons");

specter::IconAtlas<8,8> g_IconAtlas;

boo::GraphicsDataToken InitializeIcons(specter::ViewResources& viewRes)
{
    athena::io::MemoryReader r(URDE_ICONS, URDE_ICONS_SZ);
    size_t fmt = r.readUint32Big();
    if (fmt != 16)
        Log.report(logvisor::Fatal, "incorrect icon texture format");
    size_t width = r.readUint16Big();
    size_t height = r.readUint16Big();
    size_t mips = r.readUint32Big();
    size_t decompSz = r.readUint32Big();

    std::unique_ptr<uint8_t[]> texels(new uint8_t[decompSz]);
    uLongf destSz = decompSz;
    size_t pos = r.position();
    if (uncompress(texels.get(), &destSz, URDE_ICONS + pos, URDE_ICONS_SZ - pos) != Z_OK)
        Log.report(logvisor::Fatal, "unable to decompress icons");

    g_IconAtlas.initializeAtlas(viewRes.m_factory->newStaticTexture(width, height, mips, boo::TextureFormat::RGBA8,
                                                                    texels.get(), destSz));
    return viewRes.m_factory->commit();
}

specter::Icon& GetIcon(SpaceIcon icon)
{
    switch (icon)
    {
    case SpaceIcon::ResourceBrowser:
        return g_IconAtlas.getIcon(0, 0);
    case SpaceIcon::ParticleEditor:
        return g_IconAtlas.getIcon(0, 1);
    case SpaceIcon::WorldEditor:
        return g_IconAtlas.getIcon(0, 2);
    case SpaceIcon::InformationCenter:
        return g_IconAtlas.getIcon(0, 3);
    case SpaceIcon::ModelViewer:
        return g_IconAtlas.getIcon(0, 4);
    default:
        return g_IconAtlas.getIcon(6, 0);
    }
}

specter::Icon& GetIcon(MonoIcon icon)
{
    switch (icon)
    {
    case MonoIcon::Sync:
        return g_IconAtlas.getIcon(7, 0);
    case MonoIcon::Edit:
        return g_IconAtlas.getIcon(7, 1);
    case MonoIcon::Caution:
        return g_IconAtlas.getIcon(7, 2);
    case MonoIcon::Save:
        return g_IconAtlas.getIcon(7, 3);
    case MonoIcon::Filter:
        return g_IconAtlas.getIcon(7, 4);
    case MonoIcon::Document:
        return g_IconAtlas.getIcon(7, 5);
    case MonoIcon::ZoomOut:
        return g_IconAtlas.getIcon(7, 6);
    case MonoIcon::ZoomIn:
        return g_IconAtlas.getIcon(7, 7);
    case MonoIcon::Exclaim:
        return g_IconAtlas.getIcon(6, 0);
    case MonoIcon::Clock:
        return g_IconAtlas.getIcon(6, 1);
    case MonoIcon::Gamepad:
        return g_IconAtlas.getIcon(6, 2);
    case MonoIcon::Unlink:
        return g_IconAtlas.getIcon(6, 3);
    case MonoIcon::Link:
        return g_IconAtlas.getIcon(6, 4);
    case MonoIcon::Folder:
        return g_IconAtlas.getIcon(6, 5);
    case MonoIcon::Info:
        return g_IconAtlas.getIcon(6, 6);
    default:
        return g_IconAtlas.getIcon(6, 0);
    }
}

}
示例#28
0
namespace specter
{
static logvisor::Module Log("specter::ViewResources");

void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
                         const IThemeData* theme, float pf)
{
    if (!factory || !fcache || !theme)
        Log.report(logvisor::Fatal, "all arguments of ViewResources::init() must be non-null");
    m_pixelFactor = pf;
    m_factory = factory;
    m_theme = theme;
    m_fcache = fcache;
    unsigned dpi = 72.f * m_pixelFactor;

    m_curveFont = fcache->prepCurvesFont(factory, AllCharFilter, false, 8.f, dpi);

    m_resData = factory->commitTransaction(
    [&](boo::IGraphicsDataFactory::Context& ctx) -> bool
    {
        switch (ctx.platform())
        {
        case boo::IGraphicsDataFactory::Platform::OGL:
            init<boo::GLDataFactory::Context>(static_cast<boo::GLDataFactory::Context&>(ctx), *theme, fcache);
            break;
#if _WIN32
        case boo::IGraphicsDataFactory::Platform::D3D11:
        case boo::IGraphicsDataFactory::Platform::D3D12:
            init<boo::ID3DDataFactory::Context>(static_cast<boo::ID3DDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
#if BOO_HAS_METAL
        case boo::IGraphicsDataFactory::Platform::Metal:
            init<boo::MetalDataFactory::Context>(static_cast<boo::MetalDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
#if BOO_HAS_VULKAN
        case boo::IGraphicsDataFactory::Platform::Vulkan:
            init<boo::VulkanDataFactory::Context>(static_cast<boo::VulkanDataFactory::Context&>(ctx), *theme, fcache);
            break;
#endif
        default:
            Log.report(logvisor::Fatal, _S("unable to init view system for %s"), ctx.platformName());
        }
        return true;
    });
}

void ViewResources::prepFontCacheSync()
{
    unsigned dpi = 72.f * m_pixelFactor;
    if (m_fcacheInterrupt) return;
    m_mainFont = m_fcache->prepMainFont(m_factory, AllCharFilter, false, 10.f, dpi);
    if (m_fcacheInterrupt) return;
    m_monoFont = m_fcache->prepMonoFont(m_factory, AllCharFilter, false, 10.f, dpi);
    if (m_fcacheInterrupt) return;
    m_heading14 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 14.f, dpi);
    if (m_fcacheInterrupt) return;
    m_heading18 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 18.f, dpi);
    if (m_fcacheInterrupt) return;
    m_titleFont = m_fcache->prepMainFont(m_factory, LatinCharFilter, false, 36.f, dpi);
    if (m_fcacheInterrupt) return;
    m_fcache->closeBuiltinFonts();
    m_fcacheReady = true;
}

void ViewResources::prepFontCacheAsync(boo::IWindow* window)
{
    m_fcacheReady = false;
    m_fcacheThread = std::thread([this, window]()
    {
        window->getLoadContextDataFactory();
        prepFontCacheSync();
    });
}

void ViewResources::resetPixelFactor(float pf)
{
    m_pixelFactor = pf;
    unsigned dpi = 72.f * m_pixelFactor;
    m_curveFont = m_fcache->prepCurvesFont(m_factory, AllCharFilter, false, 8.f, dpi);
    prepFontCacheSync();
}

void ViewResources::resetTheme(const IThemeData* theme)
{
    m_theme = theme;
}

}
示例#29
0
namespace DNAParticle
{
logvisor::Module LogModule("urde::DNAParticle");

void RealElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('LFTW'):
        m_elem.reset(new struct RELifetimeTween);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct REConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct RETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct REAdd);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct REClamp);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct REKeyframeEmitter);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct REInitialRandom);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct RERandom);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct REMultiply);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct REPulse);
        break;
    case SBIG('SCAL'):
        m_elem.reset(new struct RETimeScale);
        break;
    case SBIG('RLPT'):
        m_elem.reset(new struct RELifetimePercent);
        break;
    case SBIG('SINE'):
        m_elem.reset(new struct RESineWave);
        break;
    case SBIG('ISWT'):
        m_elem.reset(new struct REInitialSwitch);
        break;
    case SBIG('CLTN'):
        m_elem.reset(new struct RECompareLessThan);
        break;
    case SBIG('CEQL'):
        m_elem.reset(new struct RECompareEquals);
        break;
    case SBIG('PAP1'):
        m_elem.reset(new struct REParticleAdvanceParam1);
        break;
    case SBIG('PAP2'):
        m_elem.reset(new struct REParticleAdvanceParam2);
        break;
    case SBIG('PAP3'):
        m_elem.reset(new struct REParticleAdvanceParam3);
        break;
    case SBIG('PAP4'):
        m_elem.reset(new struct REParticleAdvanceParam4);
        break;
    case SBIG('PAP5'):
        m_elem.reset(new struct REParticleAdvanceParam5);
        break;
    case SBIG('PAP6'):
        m_elem.reset(new struct REParticleAdvanceParam6);
        break;
    case SBIG('PAP7'):
        m_elem.reset(new struct REParticleAdvanceParam7);
        break;
    case SBIG('PAP8'):
        m_elem.reset(new struct REParticleAdvanceParam8);
        break;
    case SBIG('PSLL'):
        m_elem.reset(new struct REParticleSizeOrLineLength);
        break;
    case SBIG('PRLW'):
        m_elem.reset(new struct REParticleRotationOrLineWidth);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct RESubtract);
        break;
    case SBIG('VMAG'):
        m_elem.reset(new struct REVectorMagnitude);
        break;
    case SBIG('VXTR'):
        m_elem.reset(new struct REVectorXToReal);
        break;
    case SBIG('VYTR'):
        m_elem.reset(new struct REVectorYToReal);
        break;
    case SBIG('VZTR'):
        m_elem.reset(new struct REVectorZToReal);
        break;
    case SBIG('CEXT'):
        m_elem.reset(new struct RECEXT);
        break;
    case SBIG('ITRL'):
        m_elem.reset(new struct REIntTimesReal);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void RealElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t RealElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void RealElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('LFTW'):
        m_elem.reset(new struct RELifetimeTween);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct REConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct RETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct REAdd);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct REClamp);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct REKeyframeEmitter);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct REInitialRandom);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct RERandom);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct REMultiply);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct REPulse);
        break;
    case SBIG('SCAL'):
        m_elem.reset(new struct RETimeScale);
        break;
    case SBIG('RLPT'):
        m_elem.reset(new struct RELifetimePercent);
        break;
    case SBIG('SINE'):
        m_elem.reset(new struct RESineWave);
        break;
    case SBIG('ISWT'):
        m_elem.reset(new struct REInitialSwitch);
        break;
    case SBIG('CLTN'):
        m_elem.reset(new struct RECompareLessThan);
        break;
    case SBIG('CEQL'):
        m_elem.reset(new struct RECompareEquals);
        break;
    case SBIG('PAP1'):
        m_elem.reset(new struct REParticleAdvanceParam1);
        break;
    case SBIG('PAP2'):
        m_elem.reset(new struct REParticleAdvanceParam2);
        break;
    case SBIG('PAP3'):
        m_elem.reset(new struct REParticleAdvanceParam3);
        break;
    case SBIG('PAP4'):
        m_elem.reset(new struct REParticleAdvanceParam4);
        break;
    case SBIG('PAP5'):
        m_elem.reset(new struct REParticleAdvanceParam5);
        break;
    case SBIG('PAP6'):
        m_elem.reset(new struct REParticleAdvanceParam6);
        break;
    case SBIG('PAP7'):
        m_elem.reset(new struct REParticleAdvanceParam7);
        break;
    case SBIG('PAP8'):
        m_elem.reset(new struct REParticleAdvanceParam8);
        break;
    case SBIG('PSLL'):
        m_elem.reset(new struct REParticleSizeOrLineLength);
        break;
    case SBIG('PRLW'):
        m_elem.reset(new struct REParticleRotationOrLineWidth);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct RESubtract);
        break;
    case SBIG('VMAG'):
        m_elem.reset(new struct REVectorMagnitude);
        break;
    case SBIG('VXTR'):
        m_elem.reset(new struct REVectorXToReal);
        break;
    case SBIG('VYTR'):
        m_elem.reset(new struct REVectorYToReal);
        break;
    case SBIG('VZTR'):
        m_elem.reset(new struct REVectorZToReal);
        break;
    case SBIG('CEXT'):
        m_elem.reset(new struct RECEXT);
        break;
    case SBIG('ITRL'):
        m_elem.reset(new struct REIntTimesReal);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown RealElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void RealElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}


void IntElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct IEKeyframeEmitter);
        break;
    case SBIG('DETH'):
        m_elem.reset(new struct IEDeath);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct IEClamp);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct IETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct IEAdd);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct IEConstant);
        break;
    case SBIG('IMPL'):
        m_elem.reset(new struct IEImpulse);
        break;
    case SBIG('ILPT'):
        m_elem.reset(new struct IELifetimePercent);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct IEInitialRandom);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct IEPulse);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct IEMultiply);
        break;
    case SBIG('SPAH'):
        m_elem.reset(new struct IESampleAndHold);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct IERandom);
        break;
    case SBIG('TSCL'):
        m_elem.reset(new struct IETimeScale);
        break;
    case SBIG('GTCP'):
        m_elem.reset(new struct IEGTCP);
        break;
    case SBIG('MODU'):
        m_elem.reset(new struct IEModulo);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct IESubtract);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void IntElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t IntElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void IntElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct IEKeyframeEmitter);
        break;
    case SBIG('DETH'):
        m_elem.reset(new struct IEDeath);
        break;
    case SBIG('CLMP'):
        m_elem.reset(new struct IEClamp);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct IETimeChain);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct IEAdd);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct IEConstant);
        break;
    case SBIG('IMPL'):
        m_elem.reset(new struct IEImpulse);
        break;
    case SBIG('ILPT'):
        m_elem.reset(new struct IELifetimePercent);
        break;
    case SBIG('IRND'):
        m_elem.reset(new struct IEInitialRandom);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct IEPulse);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct IEMultiply);
        break;
    case SBIG('SPAH'):
        m_elem.reset(new struct IESampleAndHold);
        break;
    case SBIG('RAND'):
        m_elem.reset(new struct IERandom);
        break;
    case SBIG('TSCL'):
        m_elem.reset(new struct IETimeScale);
        break;
    case SBIG('GTCP'):
        m_elem.reset(new struct IEGTCP);
        break;
    case SBIG('MODU'):
        m_elem.reset(new struct IEModulo);
        break;
    case SBIG('SUB_'):
        m_elem.reset(new struct IESubtract);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown IntElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void IntElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}

void VectorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('CONE'):
        m_elem.reset(new struct VECone);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct VETimeChain);
        break;
    case SBIG('ANGC'):
        m_elem.reset(new struct VEAngleCone);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct VEAdd);
        break;
    case SBIG('CCLU'):
        m_elem.reset(new struct VECircleCluster);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct VEConstant);
        break;
    case SBIG('CIRC'):
        m_elem.reset(new struct VECircle);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct VEKeyframeEmitter);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct VEMultiply);
        break;
    case SBIG('RTOV'):
        m_elem.reset(new struct VERealToVector);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct VEPulse);
        break;
    case SBIG('PVEL'):
        m_elem.reset(new struct VEParticleVelocity);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct VESPOS);
        break;
    case SBIG('PLCO'):
        m_elem.reset(new struct VEPLCO);
        break;
    case SBIG('PLOC'):
        m_elem.reset(new struct VEPLOC);
        break;
    case SBIG('PSOR'):
        m_elem.reset(new struct VEPSOR);
        break;
    case SBIG('PSOF'):
        m_elem.reset(new struct VEPSOF);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void VectorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t VectorElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void VectorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('CONE'):
        m_elem.reset(new struct VECone);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct VETimeChain);
        break;
    case SBIG('ANGC'):
        m_elem.reset(new struct VEAngleCone);
        break;
    case SBIG('ADD_'):
        m_elem.reset(new struct VEAdd);
        break;
    case SBIG('CCLU'):
        m_elem.reset(new struct VECircleCluster);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct VEConstant);
        break;
    case SBIG('CIRC'):
        m_elem.reset(new struct VECircle);
        break;
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct VEKeyframeEmitter);
        break;
    case SBIG('MULT'):
        m_elem.reset(new struct VEMultiply);
        break;
    case SBIG('RTOV'):
        m_elem.reset(new struct VERealToVector);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct VEPulse);
        break;
    case SBIG('PVEL'):
        m_elem.reset(new struct VEParticleVelocity);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct VESPOS);
        break;
    case SBIG('PLCO'):
        m_elem.reset(new struct VEPLCO);
        break;
    case SBIG('PLOC'):
        m_elem.reset(new struct VEPLOC);
        break;
    case SBIG('PSOR'):
        m_elem.reset(new struct VEPSOR);
        break;
    case SBIG('PSOF'):
        m_elem.reset(new struct VEPSOF);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown VectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void VectorElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}


void ColorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct CEKeyframeEmitter);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct CEConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct CETimeChain);
        break;
    case SBIG('CFDE'):
        m_elem.reset(new struct CEFadeEnd);
        break;
    case SBIG('FADE'):
        m_elem.reset(new struct CEFade);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct CEPulse);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void ColorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t ColorElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void ColorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('KEYE'):
    case SBIG('KEYP'):
        m_elem.reset(new struct CEKeyframeEmitter);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct CEConstant);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct CETimeChain);
        break;
    case SBIG('CFDE'):
        m_elem.reset(new struct CEFadeEnd);
        break;
    case SBIG('FADE'):
        m_elem.reset(new struct CEFade);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct CEPulse);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ColorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void ColorElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}


void ModVectorElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('IMPL'):
        m_elem.reset(new struct MVEImplosion);
        break;
    case SBIG('EMPL'):
        m_elem.reset(new struct MVEExponentialImplosion);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct MVETimeChain);
        break;
    case SBIG('BNCE'):
        m_elem.reset(new struct MVEBounce);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct MVEConstant);
        break;
    case SBIG('GRAV'):
        m_elem.reset(new struct MVEGravity);
        break;
    case SBIG('EXPL'):
        m_elem.reset(new struct MVEExplode);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct MVESetPosition);
        break;
    case SBIG('LMPL'):
        m_elem.reset(new struct MVELinearImplosion);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct MVEPulse);
        break;
    case SBIG('WIND'):
        m_elem.reset(new struct MVEWind);
        break;
    case SBIG('SWRL'):
        m_elem.reset(new struct MVESwirl);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void ModVectorElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t ModVectorElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void ModVectorElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('IMPL'):
        m_elem.reset(new struct MVEImplosion);
        break;
    case SBIG('EMPL'):
        m_elem.reset(new struct MVEExponentialImplosion);
        break;
    case SBIG('CHAN'):
        m_elem.reset(new struct MVETimeChain);
        break;
    case SBIG('BNCE'):
        m_elem.reset(new struct MVEBounce);
        break;
    case SBIG('CNST'):
        m_elem.reset(new struct MVEConstant);
        break;
    case SBIG('GRAV'):
        m_elem.reset(new struct MVEGravity);
        break;
    case SBIG('EXPL'):
        m_elem.reset(new struct MVEExplode);
        break;
    case SBIG('SPOS'):
        m_elem.reset(new struct MVESetPosition);
        break;
    case SBIG('LMPL'):
        m_elem.reset(new struct MVELinearImplosion);
        break;
    case SBIG('PULS'):
        m_elem.reset(new struct MVEPulse);
        break;
    case SBIG('WIND'):
        m_elem.reset(new struct MVEWind);
        break;
    case SBIG('SWRL'):
        m_elem.reset(new struct MVESwirl);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown ModVectorElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void ModVectorElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}


void EmitterElementFactory::read(athena::io::YAMLDocReader& r)
{
    const auto& mapChildren = r.getCurNode()->m_mapChildren;
    if (mapChildren.empty())
    {
        m_elem.reset();
        return;
    }

    const auto& elem = mapChildren[0];
    if (elem.first.size() < 4)
        LogModule.report(logvisor::Fatal, "short FourCC in element '%s'", elem.first.c_str());

    switch (*reinterpret_cast<const uint32_t*>(elem.first.data()))
    {
    case SBIG('SETR'):
        m_elem.reset(new struct EESimpleEmitterTR);
        break;
    case SBIG('SEMR'):
        m_elem.reset(new struct EESimpleEmitter);
        break;
    case SBIG('SPHE'):
        m_elem.reset(new struct VESphere);
        break;
    case SBIG('ASPH'):
        m_elem.reset(new struct VEAngleSphere);
        break;
    default:
        m_elem.reset();
        return;
    }
    r.enterSubRecord(elem.first.c_str());
    m_elem->read(r);
    r.leaveSubRecord();
}

void EmitterElementFactory::write(athena::io::YAMLDocWriter& w) const
{
    if (m_elem)
    {
        w.enterSubRecord(m_elem->ClassID());
        m_elem->write(w);
        w.leaveSubRecord();
    }
}

size_t EmitterElementFactory::binarySize(size_t __isz) const
{
    if (m_elem)
        return m_elem->binarySize(__isz + 4);
    else
        return __isz + 4;
}

void EmitterElementFactory::read(athena::io::IStreamReader& r)
{
    uint32_t clsId;
    r.readBytesToBuf(&clsId, 4);
    switch (clsId)
    {
    case SBIG('SETR'):
        m_elem.reset(new struct EESimpleEmitterTR);
        break;
    case SBIG('SEMR'):
        m_elem.reset(new struct EESimpleEmitter);
        break;
    case SBIG('SPHE'):
        m_elem.reset(new struct VESphere);
        break;
    case SBIG('ASPH'):
        m_elem.reset(new struct VEAngleSphere);
        break;
    case SBIG('NONE'):
        m_elem.reset();
        return;
    default:
        m_elem.reset();
        LogModule.report(logvisor::Fatal, "Unknown EmitterElement class %.4s @%" PRIi64, &clsId, r.position());
        return;
    }
    m_elem->read(r);
}

void EmitterElementFactory::write(athena::io::IStreamWriter& w) const
{
    if (m_elem)
    {
        w.writeBytes((atInt8*)m_elem->ClassID(), 4);
        m_elem->write(w);
    }
    else
        w.writeBytes((atInt8*)"NONE", 4);
}

}
示例#30
0
文件: main.cpp 项目: KalDragon/urde
namespace urde
{
static logvisor::Module Log{"URDE"};

struct Application : boo::IApplicationCallback
{
    hecl::Runtime::FileStoreManager m_fileMgr;
    hecl::CVarManager m_cvarManager;
    std::unique_ptr<ViewManager> m_viewManager;

    bool m_running = true;

    Application() :
        m_fileMgr(_S("urde")),
        m_cvarManager(m_fileMgr)
    {
        m_viewManager.reset(new ViewManager(m_fileMgr, m_cvarManager));
    }

    int appMain(boo::IApplication* app)
    {
        initialize(app);
        m_viewManager->init(app);
        while (m_running)
        {
            if (!m_viewManager->proc())
                break;
        }
        m_viewManager->stop();
        m_cvarManager.serialize();
        m_viewManager.reset();
        return 0;
    }
    void appQuitting(boo::IApplication*)
    {
        m_running = false;
    }
    void appFilesOpen(boo::IApplication*, const std::vector<boo::SystemString>&)
    {

    }

    void initialize(boo::IApplication* app)
    {
        zeus::detectCPU();

        const zeus::CPUInfo& cpuInf = zeus::cpuFeatures();
        Log.report(logvisor::Info, "CPU Name: %s", cpuInf.cpuBrand);
        Log.report(logvisor::Info, "CPU Vendor: %s", cpuInf.cpuVendor);
        hecl::SystemString features;
        if (cpuInf.AESNI)
            features += _S("AES-NI");
        if (cpuInf.SSE1)
        {
            if (!features.empty())
                features += _S(", SSE1");
            else
                features += _S("SSE1");
        }
        else
        {
            Log.report(logvisor::Fatal, _S("URDE requires SSE1 minimum"));
            return;
        }
        if (cpuInf.SSE2)
            features += _S(", SSE2");
        else
        {
            Log.report(logvisor::Fatal, _S("URDE requires SSE2 minimum"));
            return;
        }
        if (cpuInf.SSE3)
            features += _S(", SSE3");
        if (cpuInf.SSSE3)
            features += _S(", SSSE3");
        if (cpuInf.SSE4a)
            features += _S(", SSE4a");
        if (cpuInf.SSE41)
            features += _S(", SSE4.1");
        if (cpuInf.SSE42)
            features += _S(", SSE4.2");
        Log.report(logvisor::Info, _S("CPU Features: %s"), features.c_str());
    }
};

}