mirror of https://github.com/AxioDL/metaforce.git
Tweaks for CVar integration
This commit is contained in:
parent
b431ba8686
commit
3ee468157b
|
@ -47,6 +47,7 @@ public:
|
|||
void modKeyDown(boo::EModifierKey mod, bool isRepeat);
|
||||
void modKeyUp(boo::EModifierKey mod);
|
||||
|
||||
void resetResources(ViewResources& res);
|
||||
void dispatchEvents() {m_events.dispatchEvents();}
|
||||
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||
const boo::SWindowRect& rootRect() const {return m_rootRect;}
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
boo::IGraphicsBufferD* m_splitVertsBuf;
|
||||
boo::IVertexFormat* m_splitVtxFmt; /* OpenGL only */
|
||||
boo::IShaderDataBinding* m_splitShaderBinding;
|
||||
int m_splitValidSlots = 0;
|
||||
bool m_splitValid = false;
|
||||
public:
|
||||
SplitView(ViewResources& res, View& parentView, Axis axis);
|
||||
std::unique_ptr<View> setContentView(int slot, std::unique_ptr<View>&& view);
|
||||
|
@ -78,6 +78,7 @@ public:
|
|||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||
void mouseMove(const boo::SWindowCoord&);
|
||||
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
||||
void resetResources(ViewResources& res);
|
||||
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TextView : public View
|
|||
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
|
||||
boo::IShaderDataBinding* m_shaderBinding;
|
||||
const FontAtlas& m_fontAtlas;
|
||||
int m_validSlots = 0;
|
||||
bool m_valid = false;
|
||||
|
||||
public:
|
||||
class Resources
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
RenderGlyph(int& adv, const FontAtlas::Glyph& glyph, const Zeus::CColor& defaultColor);
|
||||
};
|
||||
std::vector<RenderGlyph>& accessGlyphs() {return m_glyphs;}
|
||||
void updateGlyphs() {m_validSlots = 0;}
|
||||
void updateGlyphs() {m_valid = false;}
|
||||
|
||||
void typesetGlyphs(const std::string& str,
|
||||
const Zeus::CColor& defaultColor=Zeus::CColor::skWhite);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "CMatrix4f.hpp"
|
||||
#include "CTransform.hpp"
|
||||
#include "CColor.hpp"
|
||||
#include "HECL/CVar.hpp"
|
||||
|
||||
#include <boo/graphicsdev/GL.hpp>
|
||||
#include <boo/graphicsdev/D3D.hpp>
|
||||
|
@ -27,7 +28,7 @@ class View
|
|||
boo::IShaderDataBinding* m_bgShaderBinding;
|
||||
Zeus::CVector3f m_bgRect[4];
|
||||
Zeus::CColor m_bgColor;
|
||||
int m_bgValidSlots = 0;
|
||||
bool m_bgValid = false;
|
||||
std::unique_ptr<boo::IGraphicsData> m_gfxData;
|
||||
|
||||
friend class RootView;
|
||||
|
@ -95,12 +96,14 @@ public:
|
|||
const boo::SWindowRect& subRect() const {return m_subRect;}
|
||||
void updateSize();
|
||||
|
||||
void setBackground(Zeus::CColor color) {m_bgColor = color; m_bgValidSlots = 0;}
|
||||
void setBackground(Zeus::CColor color) {m_bgColor = color; m_bgValid = false;}
|
||||
|
||||
virtual void updateCVar(HECL::CVar* cvar) {}
|
||||
virtual void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey) {}
|
||||
virtual void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey) {}
|
||||
virtual void mouseMove(const boo::SWindowCoord&) {}
|
||||
virtual void resized(const boo::SWindowRect &root, const boo::SWindowRect& sub);
|
||||
virtual void resetResources(ViewResources& res) {}
|
||||
virtual void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
ViewResources& operator=(const ViewResources& other) = delete;
|
||||
ViewResources& operator=(ViewResources&& other) = default;
|
||||
|
||||
void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, float pixelScale);
|
||||
void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, unsigned dpi);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,11 @@ void RootView::modKeyUp(boo::EModifierKey mod)
|
|||
{
|
||||
}
|
||||
|
||||
void RootView::resetResources(ViewResources& res)
|
||||
{
|
||||
m_splitView->resetResources(res);
|
||||
}
|
||||
|
||||
void RootView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||
{
|
||||
if (m_resizeRTDirty)
|
||||
|
|
|
@ -4,13 +4,13 @@ namespace Specter
|
|||
{
|
||||
static LogVisor::LogModule Log("Specter");
|
||||
|
||||
void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache, float pixelScale)
|
||||
void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache, unsigned dpi)
|
||||
{
|
||||
m_factory = factory;
|
||||
m_mainFont = fcache->prepMainFont(factory, AllCharFilter, false, 10.0, 72 * pixelScale);
|
||||
m_monoFont = fcache->prepMonoFont(factory, AllCharFilter, false, 10.0, 72 * pixelScale);
|
||||
m_heading14 = fcache->prepMainFont(factory, LatinAndJapaneseCharFilter, false, 14.0, 72 * pixelScale);
|
||||
m_heading18 = fcache->prepMainFont(factory, LatinAndJapaneseCharFilter, false, 18.0, 72 * pixelScale);
|
||||
m_mainFont = fcache->prepMainFont(factory, AllCharFilter, false, 10.0, dpi);
|
||||
m_monoFont = fcache->prepMonoFont(factory, AllCharFilter, false, 10.0, dpi);
|
||||
m_heading14 = fcache->prepMainFont(factory, LatinAndJapaneseCharFilter, false, 14.0, dpi);
|
||||
m_heading18 = fcache->prepMainFont(factory, LatinAndJapaneseCharFilter, false, 18.0, dpi);
|
||||
switch (factory->platform())
|
||||
{
|
||||
case boo::IGraphicsDataFactory::Platform::OGL:
|
||||
|
|
|
@ -103,6 +103,14 @@ void SplitView::mouseMove(const boo::SWindowCoord& coord)
|
|||
}
|
||||
}
|
||||
|
||||
void SplitView::resetResources(ViewResources& res)
|
||||
{
|
||||
if (m_views[0])
|
||||
m_views[0]->resetResources(res);
|
||||
if (m_views[1])
|
||||
m_views[1]->resetResources(res);
|
||||
}
|
||||
|
||||
void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||
{
|
||||
View::resized(root, sub);
|
||||
|
@ -132,7 +140,7 @@ void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& su
|
|||
m_splitBlock.setViewRect(root, ssub);
|
||||
setVerticalVerts(ssub.size[1]);
|
||||
}
|
||||
m_splitValidSlots = 0;
|
||||
m_splitValid = false;
|
||||
}
|
||||
|
||||
void SplitView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||
|
@ -143,12 +151,11 @@ void SplitView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|||
if (m_views[1])
|
||||
m_views[1]->draw(gfxQ);
|
||||
|
||||
int pendingSlot = 1 << gfxQ->pendingDynamicSlot();
|
||||
if ((m_splitValidSlots & pendingSlot) == 0)
|
||||
if (!m_splitValid)
|
||||
{
|
||||
m_splitBlockBuf->load(&m_splitBlock, sizeof(VertexBlock));
|
||||
m_splitVertsBuf->load(m_splitVerts, sizeof(SplitVert) * 4);
|
||||
m_splitValidSlots |= pendingSlot;
|
||||
m_splitValid = true;
|
||||
}
|
||||
gfxQ->setShaderDataBinding(m_splitShaderBinding);
|
||||
gfxQ->draw(0, 4);
|
||||
|
|
|
@ -383,7 +383,7 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
|
|||
break;
|
||||
}
|
||||
|
||||
m_validSlots = 0;
|
||||
m_valid = false;
|
||||
}
|
||||
void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaultColor)
|
||||
{
|
||||
|
@ -411,14 +411,14 @@ void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaul
|
|||
break;
|
||||
}
|
||||
|
||||
m_validSlots = 0;
|
||||
m_valid = false;
|
||||
}
|
||||
|
||||
void TextView::colorGlyphs(const Zeus::CColor& newColor)
|
||||
{
|
||||
for (RenderGlyph& glyph : m_glyphs)
|
||||
glyph.m_color = newColor;
|
||||
m_validSlots = 0;
|
||||
m_valid = false;
|
||||
}
|
||||
void TextView::colorGlyphsTypeOn(const Zeus::CColor& newColor, float startInterval, float fadeTime)
|
||||
{
|
||||
|
@ -432,11 +432,10 @@ void TextView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|||
View::draw(gfxQ);
|
||||
if (m_glyphs.size())
|
||||
{
|
||||
int pendingSlot = 1 << gfxQ->pendingDynamicSlot();
|
||||
if ((m_validSlots & pendingSlot) == 0)
|
||||
if (!m_valid)
|
||||
{
|
||||
m_glyphBuf->load(m_glyphs.data(), m_glyphs.size() * sizeof(RenderGlyph));
|
||||
m_validSlots |= pendingSlot;
|
||||
m_valid = true;
|
||||
}
|
||||
gfxQ->setShaderDataBinding(m_shaderBinding);
|
||||
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
||||
|
|
|
@ -341,18 +341,17 @@ void View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|||
m_bgRect[1].assign(0.f, 0.f, 0.f);
|
||||
m_bgRect[2].assign(sub.size[0], sub.size[1], 0.f);
|
||||
m_bgRect[3].assign(sub.size[0], 0.f, 0.f);
|
||||
m_bgValidSlots = 0;
|
||||
m_bgValid = false;
|
||||
}
|
||||
|
||||
void View::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||
{
|
||||
int pendingSlot = 1 << gfxQ->pendingDynamicSlot();
|
||||
if ((m_bgValidSlots & pendingSlot) == 0)
|
||||
if (!m_bgValid)
|
||||
{
|
||||
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(VertexBlock));
|
||||
m_bgVertBuf->load(m_bgRect, sizeof(Zeus::CVector3f) * 4);
|
||||
m_bgInstBuf->load(&m_bgColor, sizeof(Zeus::CColor));
|
||||
m_bgValidSlots |= pendingSlot;
|
||||
m_bgValid = true;
|
||||
}
|
||||
gfxQ->setShaderDataBinding(m_bgShaderBinding);
|
||||
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
||||
|
|
Loading…
Reference in New Issue