mirror of https://github.com/AxioDL/metaforce.git
Better CMake dependency handling
This commit is contained in:
parent
285140426d
commit
0c45eb56c7
|
@ -1,35 +1,12 @@
|
|||
add_subdirectory(freetype2)
|
||||
add_definitions("-DZE_ATHENA_TYPES=1")
|
||||
if (NOT MSVC)
|
||||
target_compile_options(freetype PRIVATE -Wno-implicit-fallthrough)
|
||||
endif()
|
||||
add_subdirectory(zeus)
|
||||
set(ZEUS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/zeus/include)
|
||||
|
||||
if(NOT DEFINED HECL_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Specter may only be built as a sub-project containing hecl with
|
||||
HECL_INCLUDE_DIR set")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED BOO_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Specter may only be built as a sub-project containing boo with
|
||||
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 LOGVISOR_INCLUDE_DIR)
|
||||
message(FATAL_ERROR "Specter may only be built as a sub-project containing logvisor with
|
||||
LOGVISOR_INCLUDE_DIR set")
|
||||
endif()
|
||||
|
||||
add_subdirectory(resources/fonts)
|
||||
|
||||
include_directories(include ${HECL_INCLUDE_DIR} ${BOO_INCLUDE_DIR}
|
||||
${LOGVISOR_INCLUDE_DIR} ${ATHENA_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/freetype2/include
|
||||
${ZEUS_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
list(APPEND SPECTER_HEADERS
|
||||
include/specter/specter.hpp
|
||||
include/specter/ViewResources.hpp
|
||||
|
@ -63,8 +40,6 @@ list(APPEND SPECTER_HEADERS
|
|||
include/specter/Translator.hpp
|
||||
include/specter/genie.hpp)
|
||||
|
||||
atdna(atdna_FontCache.cpp include/specter/FontCache.hpp)
|
||||
|
||||
list(APPEND SPECTER_SOURCES
|
||||
lib/ViewResources.cpp
|
||||
lib/View.cpp
|
||||
|
@ -87,8 +62,9 @@ list(APPEND SPECTER_SOURCES
|
|||
lib/FileBrowser.cpp
|
||||
lib/Icon.cpp
|
||||
lib/FontCache.cpp
|
||||
lib/Translator.cpp
|
||||
atdna_FontCache.cpp)
|
||||
lib/Translator.cpp)
|
||||
|
||||
add_library(specter ${SPECTER_SOURCES} ${SPECTER_HEADERS})
|
||||
add_dependencies(specter hecl-light)
|
||||
target_link_libraries(specter PUBLIC specter-fonts freetype hecl-full zeus)
|
||||
target_include_directories(specter PUBLIC include freetype2/include)
|
||||
target_atdna(specter atdna_FontCache.cpp include/specter/FontCache.hpp)
|
||||
|
|
|
@ -186,7 +186,7 @@ private:
|
|||
}
|
||||
|
||||
void setSelectedRow(size_t rIdx) {
|
||||
if (rIdx != -1)
|
||||
if (rIdx != SIZE_MAX)
|
||||
m_fb.m_fileField.m_view->setText(m_entries.at(rIdx).m_name);
|
||||
else
|
||||
m_fb.m_fileField.m_view->setText("");
|
||||
|
@ -239,7 +239,7 @@ private:
|
|||
std::string_view cell(size_t, size_t rIdx) const { return m_entries.at(rIdx).m_name; }
|
||||
|
||||
void setSelectedRow(size_t rIdx) {
|
||||
if (rIdx != -1)
|
||||
if (rIdx != SIZE_MAX)
|
||||
m_fb.navigateToPath(m_entries.at(rIdx).m_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace specter {
|
||||
|
||||
struct IMenuNode {
|
||||
virtual ~IMenuNode() = default;
|
||||
virtual boo::ITexture* icon() const { return nullptr; }
|
||||
virtual const std::string* text() const { return nullptr; }
|
||||
virtual size_t subNodeCount() const { return 0; }
|
||||
|
|
|
@ -39,13 +39,13 @@ public:
|
|||
operator bool() const { return m_tex; }
|
||||
void initializeAtlas(const boo::ObjToken<boo::ITextureS>& tex) {
|
||||
m_tex = tex;
|
||||
for (int c = 0; c < COLS; ++c)
|
||||
for (int r = 0; r < ROWS; ++r)
|
||||
for (size_t c = 0; c < COLS; ++c)
|
||||
for (size_t r = 0; r < ROWS; ++r)
|
||||
m_icons[c][r] = MakeIcon(c, r);
|
||||
}
|
||||
void destroyAtlas() {
|
||||
for (int c = 0; c < COLS; ++c)
|
||||
for (int r = 0; r < ROWS; ++r)
|
||||
for (size_t c = 0; c < COLS; ++c)
|
||||
for (size_t r = 0; r < ROWS; ++r)
|
||||
m_icons[c][r].m_tex.reset();
|
||||
m_tex.reset();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class Menu : public View {
|
|||
SolidShaderVert m_hlVerts[4];
|
||||
VertexBufferBindingSolid m_hlVertsBinding;
|
||||
|
||||
size_t m_highlightedItem = -1;
|
||||
size_t m_highlightedItem = SIZE_MAX;
|
||||
void setHighlightedItem(size_t idx);
|
||||
void unsetHighlightedItem(size_t idx) {
|
||||
if (m_highlightedItem == idx)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "FontCache.hpp"
|
||||
#include "IMenuNode.hpp"
|
||||
#include "IViewManager.hpp"
|
||||
#include "optional.hpp"
|
||||
#include <optional>
|
||||
#include "boo/boo.hpp"
|
||||
|
||||
namespace specter {
|
||||
|
@ -99,7 +99,7 @@ class RootView : public View {
|
|||
}
|
||||
} m_joinActionNode;
|
||||
};
|
||||
std::experimental::optional<SplitMenuSystem> m_splitMenuSystem;
|
||||
std::optional<SplitMenuSystem> m_splitMenuSystem;
|
||||
|
||||
public:
|
||||
RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window);
|
||||
|
|
|
@ -37,14 +37,14 @@ class Table : public View {
|
|||
size_t m_maxColumns;
|
||||
size_t m_rows = 0;
|
||||
size_t m_columns = 0;
|
||||
size_t m_selectedRow = -1;
|
||||
size_t m_deferredActivation = -1;
|
||||
size_t m_selectedRow = SIZE_MAX;
|
||||
size_t m_deferredActivation = SIZE_MAX;
|
||||
size_t m_clickFrames = 15;
|
||||
|
||||
struct CellView : public View {
|
||||
Table& m_t;
|
||||
std::unique_ptr<TextView> m_text;
|
||||
size_t m_c, m_r;
|
||||
size_t m_c = SIZE_MAX, m_r = SIZE_MAX;
|
||||
boo::SWindowRect m_scissorRect;
|
||||
uint64_t m_textHash = 0;
|
||||
CellView(Table& t, ViewResources& res);
|
||||
|
@ -68,7 +68,7 @@ class Table : public View {
|
|||
std::vector<ColumnPool> m_cellPools;
|
||||
size_t m_ensuredRows = 0;
|
||||
std::vector<ColumnPool>& ensureCellPools(size_t rows, size_t cols, ViewResources& res);
|
||||
size_t m_activePool = -1;
|
||||
size_t m_activePool = SIZE_MAX;
|
||||
bool m_header = false;
|
||||
|
||||
std::vector<boo::SWindowRect> m_hCellRects;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "boo/boo.hpp"
|
||||
#include "optional.hpp"
|
||||
#include <optional>
|
||||
#include "zeus/CVector3f.hpp"
|
||||
#include "zeus/CMatrix4f.hpp"
|
||||
#include "zeus/CTransform.hpp"
|
||||
|
|
|
@ -112,14 +112,14 @@ void Menu::setVerts(int width, int height, float pf) {
|
|||
}
|
||||
|
||||
void Menu::ContentView::setHighlightedItem(size_t idx) {
|
||||
if (idx == -1) {
|
||||
m_highlightedItem = -1;
|
||||
if (idx == SIZE_MAX) {
|
||||
m_highlightedItem = SIZE_MAX;
|
||||
return;
|
||||
}
|
||||
ViewChild<std::unique_ptr<ItemView>>& vc = m_menu.m_items[idx];
|
||||
|
||||
if (!vc.m_view) {
|
||||
m_highlightedItem = -1;
|
||||
m_highlightedItem = SIZE_MAX;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ void Menu::draw(boo::IGraphicsCommandQueue* gfxQ) {
|
|||
void Menu::ContentView::draw(boo::IGraphicsCommandQueue* gfxQ) {
|
||||
View::draw(gfxQ);
|
||||
gfxQ->setScissor(m_scissorRect);
|
||||
if (m_highlightedItem != -1) {
|
||||
if (m_highlightedItem != SIZE_MAX) {
|
||||
gfxQ->setShaderDataBinding(m_hlVertsBinding);
|
||||
gfxQ->draw(0, 4);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ static logvisor::Module Log("specter::MultiLineTextView");
|
|||
std::string MultiLineTextView::LineWrap(std::string_view str, int wrap) {
|
||||
size_t rem = str.size();
|
||||
const utf8proc_uint8_t* it = reinterpret_cast<const utf8proc_uint8_t*>(str.data());
|
||||
uint32_t lCh = -1;
|
||||
uint32_t lCh = UINT32_MAX;
|
||||
int adv = 0;
|
||||
|
||||
std::string ret;
|
||||
|
@ -37,14 +37,14 @@ std::string MultiLineTextView::LineWrap(std::string_view str, int wrap) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (lCh != -1)
|
||||
if (lCh != UINT32_MAX)
|
||||
adv += TextView::DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
|
||||
adv += glyph->m_advance;
|
||||
|
||||
if (adv > wrap && lastSpaceIt) {
|
||||
ret.assign(ret.cbegin(), ret.cbegin() + rollbackPos);
|
||||
ret += '\n';
|
||||
lCh = -1;
|
||||
lCh = UINT32_MAX;
|
||||
rem = lastSpaceRem;
|
||||
it = lastSpaceIt;
|
||||
lastSpaceIt = nullptr;
|
||||
|
@ -68,7 +68,7 @@ std::string MultiLineTextView::LineWrap(std::string_view str, int wrap) {
|
|||
}
|
||||
|
||||
std::wstring MultiLineTextView::LineWrap(std::wstring_view str, int wrap) {
|
||||
uint32_t lCh = -1;
|
||||
uint32_t lCh = UINT32_MAX;
|
||||
int adv = 0;
|
||||
|
||||
std::wstring ret;
|
||||
|
@ -89,14 +89,14 @@ std::wstring MultiLineTextView::LineWrap(std::wstring_view str, int wrap) {
|
|||
if (!glyph)
|
||||
continue;
|
||||
|
||||
if (lCh != -1)
|
||||
if (lCh != UINT32_MAX)
|
||||
adv += TextView::DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
|
||||
adv += glyph->m_advance;
|
||||
|
||||
if (adv > wrap && lastSpaceIt != str.cend()) {
|
||||
ret.assign(ret.cbegin(), ret.cbegin() + rollbackPos);
|
||||
ret += L'\n';
|
||||
lCh = -1;
|
||||
lCh = UINT32_MAX;
|
||||
it = lastSpaceIt;
|
||||
lastSpaceIt = str.cend();
|
||||
adv = 0;
|
||||
|
|
|
@ -41,7 +41,7 @@ Table::RowsView::RowsView(Table& t, ViewResources& res)
|
|||
}
|
||||
|
||||
Table::CellView::CellView(Table& t, ViewResources& res)
|
||||
: View(res, t), m_t(t), m_text(new TextView(res, *this, res.m_mainFont)), m_c(-1), m_r(-1) {}
|
||||
: View(res, t), m_t(t), m_text(new TextView(res, *this, res.m_mainFont)) {}
|
||||
|
||||
void Table::_setHeaderVerts(const boo::SWindowRect& sub) {
|
||||
;
|
||||
|
@ -164,7 +164,7 @@ void Table::RowsView::_setRowVerts(const boo::SWindowRect& sub, const boo::SWind
|
|||
}
|
||||
m_visibleStart = std::max(0, startIdx);
|
||||
m_visibleRows = r;
|
||||
if (r * c)
|
||||
if (r && c)
|
||||
m_vertsBinding.load(m_verts.get(), 6 * r * c);
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ void Table::cycleSortColumn(size_t c) {
|
|||
void Table::selectRow(size_t r) {
|
||||
if (m_inSelectRow)
|
||||
return;
|
||||
if (r >= m_rows && r != -1)
|
||||
if (r >= m_rows && r != SIZE_MAX)
|
||||
Log.report(logvisor::Fatal, "selectRow out of bounds (%" PRISize ", %" PRISize ")", r, m_rows);
|
||||
if (r == m_selectedRow) {
|
||||
if (m_state) {
|
||||
|
@ -197,7 +197,7 @@ void Table::selectRow(size_t r) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_selectedRow != -1 && m_activePool != -1) {
|
||||
if (m_selectedRow != SIZE_MAX && m_activePool != SIZE_MAX) {
|
||||
size_t poolIdx = m_selectedRow / SPECTER_TABLE_MAX_ROWS;
|
||||
int pool0 = (poolIdx & 1) != 0;
|
||||
int pool1 = (poolIdx & 1) == 0;
|
||||
|
@ -218,7 +218,7 @@ void Table::selectRow(size_t r) {
|
|||
|
||||
m_selectedRow = r;
|
||||
|
||||
if (m_selectedRow != -1 && m_activePool != -1) {
|
||||
if (m_selectedRow != SIZE_MAX && m_activePool != SIZE_MAX) {
|
||||
size_t poolIdx = m_selectedRow / SPECTER_TABLE_MAX_ROWS;
|
||||
int pool0 = (poolIdx & 1) != 0;
|
||||
int pool1 = (poolIdx & 1) == 0;
|
||||
|
@ -296,9 +296,9 @@ void Table::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button,
|
|||
if (m_headerNeedsUpdate)
|
||||
_setHeaderVerts(subRect());
|
||||
|
||||
if (m_deferredActivation != -1 && m_state) {
|
||||
if (m_deferredActivation != SIZE_MAX && m_state) {
|
||||
m_state->rowActivated(m_deferredActivation);
|
||||
m_deferredActivation = -1;
|
||||
m_deferredActivation = SIZE_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ void Table::RowsView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButto
|
|||
}
|
||||
|
||||
void Table::CellView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
||||
if (m_r != -1) {
|
||||
if (m_r != SIZE_MAX) {
|
||||
m_t.selectRow(m_r);
|
||||
if (m_t.m_clickFrames < 15)
|
||||
m_t.m_deferredActivation = m_r;
|
||||
|
@ -352,7 +352,7 @@ void Table::RowsView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton
|
|||
}
|
||||
|
||||
void Table::CellView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod) {
|
||||
if (m_r == -1)
|
||||
if (m_r == SIZE_MAX)
|
||||
m_t.m_headerNeedsUpdate = true;
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ void Table::mouseEnter(const boo::SWindowCoord& coord) {
|
|||
}
|
||||
|
||||
void Table::CellView::mouseEnter(const boo::SWindowCoord& coord) {
|
||||
if (m_r == -1)
|
||||
if (m_r == SIZE_MAX)
|
||||
m_t.m_headerNeedsUpdate = true;
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ void Table::RowsView::mouseLeave(const boo::SWindowCoord& coord) {
|
|||
}
|
||||
|
||||
void Table::CellView::mouseLeave(const boo::SWindowCoord& coord) {
|
||||
if (m_r == -1)
|
||||
if (m_r == SIZE_MAX)
|
||||
m_t.m_headerNeedsUpdate = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void TextView::typesetGlyphs(std::string_view str, const zeus::CColor& defaultCo
|
|||
_commitResources(charLen);
|
||||
}
|
||||
|
||||
uint32_t lCh = -1;
|
||||
uint32_t lCh = UINT32_MAX;
|
||||
m_glyphs.clear();
|
||||
m_glyphs.reserve(charLen);
|
||||
m_glyphInfo.clear();
|
||||
|
@ -115,7 +115,7 @@ void TextView::typesetGlyphs(std::string_view str, const zeus::CColor& defaultCo
|
|||
if (!glyph)
|
||||
continue;
|
||||
|
||||
if (lCh != -1)
|
||||
if (lCh != UINT32_MAX)
|
||||
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
|
||||
m_glyphs.emplace_back(adv, *glyph, defaultColor);
|
||||
m_glyphInfo.emplace_back(ch, glyph->m_width, glyph->m_height, adv);
|
||||
|
@ -157,7 +157,7 @@ void TextView::typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultC
|
|||
_commitResources(charLen);
|
||||
}
|
||||
|
||||
uint32_t lCh = -1;
|
||||
uint32_t lCh = UINT32_MAX;
|
||||
m_glyphs.clear();
|
||||
m_glyphs.reserve(charLen);
|
||||
m_glyphInfo.clear();
|
||||
|
@ -172,7 +172,7 @@ void TextView::typesetGlyphs(std::wstring_view str, const zeus::CColor& defaultC
|
|||
if (!glyph)
|
||||
continue;
|
||||
|
||||
if (lCh != -1)
|
||||
if (lCh != UINT32_MAX)
|
||||
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
|
||||
m_glyphs.emplace_back(adv, *glyph, defaultColor);
|
||||
m_glyphInfo.emplace_back(ch, glyph->m_width, glyph->m_height, adv);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6c13d089fe5c0828fb6111c874e09c47e1c1bddd
|
||||
Subproject commit c81eb93b6d008b4bbf09df6ead11a4109c5fd105
|
Loading…
Reference in New Issue