v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
62
source/frontend/StarInterfaceCursor.cpp
Normal file
62
source/frontend/StarInterfaceCursor.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include "StarInterfaceCursor.hpp"
|
||||
#include "StarJsonExtra.hpp"
|
||||
#include "StarRoot.hpp"
|
||||
#include "StarAssets.hpp"
|
||||
#include "StarImageMetadataDatabase.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
InterfaceCursor::InterfaceCursor() {
|
||||
resetCursor();
|
||||
}
|
||||
|
||||
void InterfaceCursor::resetCursor() {
|
||||
auto& root = Root::singleton();
|
||||
auto assets = root.assets();
|
||||
setCursor(assets->json("/interface.config:defaultCursor").toString());
|
||||
}
|
||||
|
||||
void InterfaceCursor::setCursor(String const& configFile) {
|
||||
if (m_configFile == configFile)
|
||||
return;
|
||||
|
||||
m_configFile = configFile;
|
||||
|
||||
auto& root = Root::singleton();
|
||||
auto assets = root.assets();
|
||||
auto imageMetadata = root.imageMetadataDatabase();
|
||||
|
||||
auto config = assets->json(m_configFile);
|
||||
|
||||
m_offset = jsonToVec2I(config.get("offset"));
|
||||
if (config.contains("image")) {
|
||||
m_drawable = config.getString("image");
|
||||
m_size = Vec2I{imageMetadata->imageSize(config.getString("image"))};
|
||||
} else {
|
||||
m_drawable = Animation(config.get("animation"), "/interface");
|
||||
m_size = Vec2I(m_drawable.get<Animation>().drawable(1.0f).boundBox(false).size());
|
||||
}
|
||||
}
|
||||
|
||||
Drawable InterfaceCursor::drawable() const {
|
||||
if (m_drawable.is<String>())
|
||||
return Drawable::makeImage(m_drawable.get<String>(), 1.0f, false, {});
|
||||
else
|
||||
return m_drawable.get<Animation>().drawable(1.0f);
|
||||
}
|
||||
|
||||
Vec2I InterfaceCursor::size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
Vec2I InterfaceCursor::offset() const {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
void InterfaceCursor::update(float dt) {
|
||||
if (m_drawable.is<Animation>()) {
|
||||
m_drawable.get<Animation>().update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue