mirror of https://github.com/AxioDL/metaforce.git
architectural tweaks
This commit is contained in:
parent
2f1b7cfc40
commit
2df0f7873d
|
@ -10,9 +10,20 @@ if(NOT DEFINED BOO_INCLUDE_DIR)
|
|||
BOO_INCLUDE_DIR set")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED ATHENA_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Specter may only be built as a sub-project containing Athena with
|
||||
ATHENA_INCLUDE_DIR set")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED LOG_VISOR_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Specter may only be built as a sub-project containing LogVisor with
|
||||
LOG_VISOR_INCLUDE_DIR set")
|
||||
endif()
|
||||
|
||||
add_subdirectory(resources/fonts)
|
||||
|
||||
include_directories(include ${HECL_INCLUDE_DIR} ${BOO_INCLUDE_DIR}
|
||||
${LOG_VISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/freetype2/include)
|
||||
|
||||
list(APPEND SPECTER_HEADERS
|
||||
|
|
|
@ -4,11 +4,35 @@
|
|||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include <boo/boo.hpp>
|
||||
#include <HECL/Runtime.hpp>
|
||||
|
||||
namespace Specter
|
||||
{
|
||||
|
||||
class FontHandle
|
||||
{
|
||||
};
|
||||
|
||||
class FontAtlas
|
||||
{
|
||||
FT_Face m_face;
|
||||
std::vector<boo::ITextureS*> m_texs;
|
||||
};
|
||||
|
||||
class FontCache
|
||||
{
|
||||
const HECL::Runtime::FileStoreManager& m_fileMgr;
|
||||
FT_Library m_fontLib;
|
||||
FT_Face m_regFace;
|
||||
FT_Face m_monoFace;
|
||||
public:
|
||||
FontCache(const HECL::Runtime::FileStoreManager& fileMgr);
|
||||
~FontCache();
|
||||
|
||||
FontHandle prepMainFont(float points=10.0);
|
||||
FontHandle prepMonoFont(float points=10.0);
|
||||
FontHandle prepCustomFont(FT_Face face, float points=10.0);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -2,19 +2,17 @@
|
|||
#define SPECTER_ROOTVIEW_HPP
|
||||
|
||||
#include "View.hpp"
|
||||
#include "FontCache.hpp"
|
||||
#include <boo/boo.hpp>
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
namespace Specter
|
||||
{
|
||||
|
||||
class RootView : public View, public boo::IWindowCallback
|
||||
{
|
||||
FontCache& m_fontCache;
|
||||
boo::IWindow* m_window = nullptr;
|
||||
FT_Library m_ftLib;
|
||||
|
||||
void setWindow(boo::IWindow* window);
|
||||
float m_scale = 1.0;
|
||||
|
||||
void resized(const boo::SWindowRect& rect);
|
||||
void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods);
|
||||
|
@ -36,6 +34,10 @@ class RootView : public View, public boo::IWindowCallback
|
|||
void modKeyUp(boo::EModifierKey mod);
|
||||
|
||||
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||
|
||||
public:
|
||||
RootView(FontCache& fontCache) : m_fontCache(fontCache) {}
|
||||
void setWindow(boo::IWindow* window, float userScale);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
#include "Menu.hpp"
|
||||
#include "Node.hpp"
|
||||
#include "NodeSocket.hpp"
|
||||
#include "FontCache.hpp"
|
||||
|
||||
#endif // SPECTER_HPP
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#include "Specter/FontCache.hpp"
|
||||
#include <LogVisor/LogVisor.hpp>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" uint8_t* DROIDSANS_PERMISSIVE;
|
||||
extern "C" size_t DROIDSANS_PERMISSIVE_SZ;
|
||||
|
||||
extern "C" uint8_t* BMONOFONT;
|
||||
extern "C" size_t BMONOFONT_SZ;
|
||||
|
||||
namespace Specter
|
||||
{
|
||||
static LogVisor::LogModule Log("Specter::FontCache");
|
||||
|
||||
FontCache::FontCache(const HECL::Runtime::FileStoreManager& fileMgr)
|
||||
: m_fileMgr(fileMgr)
|
||||
{
|
||||
FT_Error err = FT_Init_FreeType(&m_fontLib);
|
||||
if (err)
|
||||
Log.report(LogVisor::FatalError, "unable to FT_Init_FreeType");
|
||||
err = FT_New_Memory_Face(m_fontLib, DROIDSANS_PERMISSIVE, DROIDSANS_PERMISSIVE_SZ, 0, &m_regFace);
|
||||
if (err)
|
||||
Log.report(LogVisor::FatalError, "unable to FT_New_Memory_Face for main UI font");
|
||||
err = FT_New_Memory_Face(m_fontLib, BMONOFONT, BMONOFONT_SZ, 0, &m_monoFace);
|
||||
if (err)
|
||||
Log.report(LogVisor::FatalError, "unable to FT_New_Memory_Face for mono UI font");
|
||||
}
|
||||
|
||||
FontCache::~FontCache()
|
||||
{
|
||||
FT_Done_FreeType(m_fontLib);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,10 +3,11 @@
|
|||
namespace Specter
|
||||
{
|
||||
|
||||
void RootView::setWindow(boo::IWindow* window)
|
||||
void RootView::setWindow(boo::IWindow* window, float userScale)
|
||||
{
|
||||
window->setCallback(this);
|
||||
m_window = window;
|
||||
float pf = window->getVirtualPixelFactor();
|
||||
m_scale = window->getVirtualPixelFactor() * userScale;
|
||||
}
|
||||
|
||||
void RootView::resized(const boo::SWindowRect& rect)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
bintoc(droidsans-permissive.cpp droidsans-permissive.ttf.gz DROIDSANS_PERMISSIVE)
|
||||
bintoc(bmonofont-i18n.cpp bmonofont-i18n.ttf.gz BMONOFONT)
|
||||
add_library(SpecterFonts droidsans-permissive.cpp bmonofont-i18n.cpp)
|
||||
bintoc(droidsans-permissive.c droidsans-permissive.ttf.gz DROIDSANS_PERMISSIVE)
|
||||
bintoc(bmonofont-i18n.c bmonofont-i18n.ttf.gz BMONOFONT)
|
||||
add_library(SpecterFonts droidsans-permissive.c bmonofont-i18n.c)
|
||||
|
|
Loading…
Reference in New Issue