bunch of optimizations
This commit is contained in:
parent
3cd31bcd1e
commit
b4261a8c7b
|
@ -136,6 +136,7 @@ SET(framework_SOURCES ${framework_SOURCES}
|
||||||
|
|
||||||
# framework util
|
# framework util
|
||||||
${CMAKE_CURRENT_LIST_DIR}/util/utf8.cpp
|
${CMAKE_CURRENT_LIST_DIR}/util/utf8.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/math/color.cpp
|
||||||
|
|
||||||
# framework core
|
# framework core
|
||||||
${CMAKE_CURRENT_LIST_DIR}/core/logger.cpp
|
${CMAKE_CURRENT_LIST_DIR}/core/logger.cpp
|
||||||
|
|
|
@ -30,30 +30,7 @@
|
||||||
|
|
||||||
namespace Fw
|
namespace Fw
|
||||||
{
|
{
|
||||||
constexpr double pi = 3.14159265;
|
constexpr float pi = 3.14159265;
|
||||||
|
|
||||||
// NOTE: AABBGGRR order
|
|
||||||
enum GlobalColor : uint32 {
|
|
||||||
alpha = 0x00000000,
|
|
||||||
white = 0xffffffff,
|
|
||||||
black = 0xff000000,
|
|
||||||
red = 0xff0000ff,
|
|
||||||
darkRed = 0xff000080,
|
|
||||||
green = 0xff00ff00,
|
|
||||||
darkGreen = 0xff008000,
|
|
||||||
blue = 0xffff0000,
|
|
||||||
darkBlue = 0xff800000,
|
|
||||||
pink = 0xffff00ff,
|
|
||||||
darkPink = 0xff800080,
|
|
||||||
yellow = 0xff00ffff,
|
|
||||||
darkYellow = 0xff008080,
|
|
||||||
teal = 0xffffff00,
|
|
||||||
darkTeal = 0xff808000,
|
|
||||||
gray = 0xffa0a0a0,
|
|
||||||
darkGray = 0xff808080,
|
|
||||||
lightGray = 0xffc0c0c0,
|
|
||||||
orange = 0xffff8c00
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Key : uint8 {
|
enum Key : uint8 {
|
||||||
KeyUnknown = 0,
|
KeyUnknown = 0,
|
||||||
|
|
|
@ -37,6 +37,7 @@ ticks_t Clock::updateTicks()
|
||||||
{
|
{
|
||||||
auto timeNow = std::chrono::high_resolution_clock::now();
|
auto timeNow = std::chrono::high_resolution_clock::now();
|
||||||
m_currentTicks = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow - m_startupTime).count();
|
m_currentTicks = std::chrono::duration_cast<std::chrono::milliseconds>(timeNow - m_startupTime).count();
|
||||||
|
m_currentTime = m_currentTicks/1000.0f;
|
||||||
return m_currentTicks;
|
return m_currentTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,16 @@ public:
|
||||||
void sleep(int ms);
|
void sleep(int ms);
|
||||||
|
|
||||||
ticks_t ticks() { return m_currentTicks; }
|
ticks_t ticks() { return m_currentTicks; }
|
||||||
ticks_t ticksElapsed(long prevTicks) { return ticks() - prevTicks; }
|
ticks_t ticksElapsed(long prevTicks) { return m_currentTicks - prevTicks; }
|
||||||
ticks_t ticksFor(int delay) { return ticks() + delay; }
|
ticks_t ticksFor(int delay) { return m_currentTicks + delay; }
|
||||||
|
|
||||||
double time() { return m_currentTicks/1000.0; }
|
float time() { return m_currentTime; }
|
||||||
double timeElapsed(double prevTime) { return time() - prevTime; }
|
float timeElapsed(float prevTime) { return m_currentTime - prevTime; }
|
||||||
double timeFor(double delay) { return time() + delay; }
|
float timeFor(float delay) { return m_currentTime + delay; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ticks_t m_currentTicks;
|
ticks_t m_currentTicks;
|
||||||
|
float m_currentTime;
|
||||||
std::chrono::system_clock::time_point m_startupTime;
|
std::chrono::system_clock::time_point m_startupTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
|
|
||||||
ticks_t startTicks() { return m_startTicks; }
|
ticks_t startTicks() { return m_startTicks; }
|
||||||
ticks_t ticksElapsed();
|
ticks_t ticksElapsed();
|
||||||
double timeElapsed() { return ticksElapsed()/1000.0; }
|
float timeElapsed() { return ticksElapsed()/1000.0f; }
|
||||||
|
|
||||||
bool running() { return !m_stopped; }
|
bool running() { return !m_stopped; }
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ void CoordsBuffer::cacheVertexArrays()
|
||||||
m_vertices.clear();
|
m_vertices.clear();
|
||||||
m_textureCoords.clear();
|
m_textureCoords.clear();
|
||||||
|
|
||||||
for(int i=0;i<numDestRects;++i) {
|
for(register int i=0;i<numDestRects;++i) {
|
||||||
m_vertices.addRect(m_destRects[i]);
|
m_vertices.addRect(m_destRects[i]);
|
||||||
if(numSrcRects == numDestRects)
|
if(numSrcRects == numDestRects)
|
||||||
m_textureCoords.addRect(m_srcRects[i]);
|
m_textureCoords.addRect(m_srcRects[i]);
|
||||||
|
|
|
@ -38,13 +38,13 @@ public:
|
||||||
/// Simple text render starting at startPos
|
/// Simple text render starting at startPos
|
||||||
void renderText(const std::string& text,
|
void renderText(const std::string& text,
|
||||||
const Point& startPos,
|
const Point& startPos,
|
||||||
const Color& color = Fw::white);
|
const Color& color = Color::white);
|
||||||
|
|
||||||
/// Advanced text render delimited by a screen region and alignment
|
/// Advanced text render delimited by a screen region and alignment
|
||||||
void renderText(const std::string& text,
|
void renderText(const std::string& text,
|
||||||
const Rect& screenCoords,
|
const Rect& screenCoords,
|
||||||
Fw::AlignmentFlag align = Fw::AlignTopLeft,
|
Fw::AlignmentFlag align = Fw::AlignTopLeft,
|
||||||
const Color& color = Fw::white);
|
const Color& color = Color::white);
|
||||||
|
|
||||||
/// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted
|
/// Calculate glyphs positions to use on render, also calculates textBoxSize if wanted
|
||||||
const std::vector<Point>& calculateGlyphsPositions(const std::string& text,
|
const std::vector<Point>& calculateGlyphsPositions(const std::string& text,
|
||||||
|
|
|
@ -28,7 +28,7 @@ uint FrameBuffer::boundFbo = 0;
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer()
|
FrameBuffer::FrameBuffer()
|
||||||
{
|
{
|
||||||
m_clearColor = Fw::alpha;
|
m_clearColor = Color::alpha;
|
||||||
|
|
||||||
glGenFramebuffers(1, &m_fbo);
|
glGenFramebuffers(1, &m_fbo);
|
||||||
if(!m_fbo)
|
if(!m_fbo)
|
||||||
|
@ -37,7 +37,7 @@ FrameBuffer::FrameBuffer()
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer(const Size& size)
|
FrameBuffer::FrameBuffer(const Size& size)
|
||||||
{
|
{
|
||||||
m_clearColor = Fw::alpha;
|
m_clearColor = Color::alpha;
|
||||||
|
|
||||||
glGenFramebuffers(1, &m_fbo);
|
glGenFramebuffers(1, &m_fbo);
|
||||||
if(!m_fbo)
|
if(!m_fbo)
|
||||||
|
|
|
@ -32,7 +32,7 @@ Painter g_painter;
|
||||||
|
|
||||||
void Painter::init()
|
void Painter::init()
|
||||||
{
|
{
|
||||||
setColor(Fw::white);
|
setColor(Color::white);
|
||||||
setOpacity(1.0f);
|
setOpacity(1.0f);
|
||||||
setCompositionMode(CompositionMode_Normal);
|
setCompositionMode(CompositionMode_Normal);
|
||||||
|
|
||||||
|
@ -67,16 +67,11 @@ void Painter::drawProgram(const PainterShaderProgramPtr& program, CoordsBuffer&
|
||||||
|
|
||||||
void Painter::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture)
|
void Painter::drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture)
|
||||||
{
|
{
|
||||||
PainterShaderProgramPtr program = m_customProgram ? m_customProgram : m_drawTexturedProgram;
|
PainterShaderProgramPtr& program = m_customProgram ? m_customProgram : m_drawTexturedProgram;
|
||||||
program->setTexture(texture);
|
program->setTexture(texture);
|
||||||
drawProgram(program, coordsBuffer);
|
drawProgram(program, coordsBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Painter::drawTexturedRect(const Rect& dest, const TexturePtr& texture)
|
|
||||||
{
|
|
||||||
drawTexturedRect(dest, texture, Rect(Point(0,0), texture->getSize()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Painter::drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src)
|
void Painter::drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src)
|
||||||
{
|
{
|
||||||
if(dest.isEmpty() || src.isEmpty() || !texture->getId())
|
if(dest.isEmpty() || src.isEmpty() || !texture->getId())
|
||||||
|
@ -153,7 +148,7 @@ void Painter::saveAndResetState()
|
||||||
m_oldCompostionMode = m_compostionMode;
|
m_oldCompostionMode = m_compostionMode;
|
||||||
|
|
||||||
releaseCustomProgram();
|
releaseCustomProgram();
|
||||||
setColor(Fw::white);
|
setColor(Color::white);
|
||||||
setOpacity(1);
|
setOpacity(1);
|
||||||
setCompositionMode(CompositionMode_Normal);
|
setCompositionMode(CompositionMode_Normal);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +161,7 @@ void Painter::restoreSavedState()
|
||||||
setCompositionMode(m_oldCompostionMode);
|
setCompositionMode(m_oldCompostionMode);
|
||||||
|
|
||||||
m_oldCustomProgram = nullptr;
|
m_oldCustomProgram = nullptr;
|
||||||
m_oldColor = Fw::white;
|
m_oldColor = Color::white;
|
||||||
m_oldOpacity = 1;
|
m_oldOpacity = 1;
|
||||||
m_oldCompostionMode = CompositionMode_Normal;
|
m_oldCompostionMode = CompositionMode_Normal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <framework/util/databuffer.h>
|
#include <framework/util/databuffer.h>
|
||||||
#include "coordsbuffer.h"
|
#include "coordsbuffer.h"
|
||||||
#include "paintershaderprogram.h"
|
#include "paintershaderprogram.h"
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
class Painter
|
class Painter
|
||||||
{
|
{
|
||||||
|
@ -44,8 +45,8 @@ public:
|
||||||
|
|
||||||
void drawProgram(const PainterShaderProgramPtr& program, CoordsBuffer& coordsBuffer, PainterShaderProgram::DrawMode drawMode = PainterShaderProgram::Triangles);
|
void drawProgram(const PainterShaderProgramPtr& program, CoordsBuffer& coordsBuffer, PainterShaderProgram::DrawMode drawMode = PainterShaderProgram::Triangles);
|
||||||
void drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture);
|
void drawTextureCoords(CoordsBuffer& coordsBuffer, const TexturePtr& texture);
|
||||||
void drawTexturedRect(const Rect& dest, const TexturePtr& texture);
|
|
||||||
void drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
|
void drawTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
|
||||||
|
void drawTexturedRect(const Rect& dest, const TexturePtr& texture) { drawTexturedRect(dest, texture, Rect(Point(0,0), texture->getSize())); }
|
||||||
void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
|
void drawRepeatedTexturedRect(const Rect& dest, const TexturePtr& texture, const Rect& src);
|
||||||
void drawFilledRect(const Rect& dest);
|
void drawFilledRect(const Rect& dest);
|
||||||
void drawBoundingRect(const Rect& dest, int innerLineWidth = 1);
|
void drawBoundingRect(const Rect& dest, int innerLineWidth = 1);
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
PainterShaderProgram::PainterShaderProgram()
|
PainterShaderProgram::PainterShaderProgram()
|
||||||
{
|
{
|
||||||
m_textures.fill(std::make_tuple(-1, 0));
|
m_textures.fill(std::make_tuple(-1, 0));
|
||||||
|
m_startTime = g_clock.time();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PainterShaderProgram::link()
|
bool PainterShaderProgram::link()
|
||||||
|
@ -44,7 +45,7 @@ bool PainterShaderProgram::link()
|
||||||
bindUniformLocation(TIME_UNIFORM, "time");
|
bindUniformLocation(TIME_UNIFORM, "time");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
m_startTimer.restart();
|
m_startTime = g_clock.time();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ void PainterShaderProgram::draw(const CoordsBuffer& coordsBuffer, DrawMode drawM
|
||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
|
|
||||||
setUniformValue(TIME_UNIFORM, (float)m_startTimer.timeElapsed());
|
setUniformValue(TIME_UNIFORM, g_clock.timeElapsed(m_startTime));
|
||||||
|
|
||||||
int numVertices = coordsBuffer.getVertexCount();
|
int numVertices = coordsBuffer.getVertexCount();
|
||||||
if(numVertices == 0)
|
if(numVertices == 0)
|
||||||
|
|
|
@ -58,7 +58,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DrawMode m_drawMode;
|
DrawMode m_drawMode;
|
||||||
Timer m_startTimer;
|
float m_startTime;
|
||||||
std::array<std::tuple<int, int>, 4> m_textures;
|
std::array<std::tuple<int, int>, 4> m_textures;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ void Particle::render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Particle::update(double elapsedTime)
|
void Particle::update(float elapsedTime)
|
||||||
{
|
{
|
||||||
// check if finished
|
// check if finished
|
||||||
if(m_duration >= 0 && m_elapsedTime >= m_duration) {
|
if(m_duration >= 0 && m_elapsedTime >= m_duration) {
|
||||||
|
@ -71,7 +71,7 @@ void Particle::update(double elapsedTime)
|
||||||
m_elapsedTime += elapsedTime;
|
m_elapsedTime += elapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Particle::updatePosition(double elapsedTime)
|
void Particle::updatePosition(float elapsedTime)
|
||||||
{
|
{
|
||||||
if(m_ignorePhysicsAfter < 0 || m_elapsedTime < m_ignorePhysicsAfter ) {
|
if(m_ignorePhysicsAfter < 0 || m_elapsedTime < m_ignorePhysicsAfter ) {
|
||||||
// update position
|
// update position
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
Particle(const Point& pos, const Size& startSize, const Size& finalSize, const PointF& velocity, const PointF& acceleration, float duration, float ignorePhysicsAfter, const std::vector<Color>& colors, const std::vector<float>& colorsStops, Painter::CompositionMode compositionMode = Painter::CompositionMode_Normal, TexturePtr texture = nullptr);
|
Particle(const Point& pos, const Size& startSize, const Size& finalSize, const PointF& velocity, const PointF& acceleration, float duration, float ignorePhysicsAfter, const std::vector<Color>& colors, const std::vector<float>& colorsStops, Painter::CompositionMode compositionMode = Painter::CompositionMode_Normal, TexturePtr texture = nullptr);
|
||||||
|
|
||||||
void render();
|
void render();
|
||||||
void update(double elapsedTime);
|
void update(float elapsedTime);
|
||||||
|
|
||||||
bool hasFinished() { return m_finished; }
|
bool hasFinished() { return m_finished; }
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateColor();
|
void updateColor();
|
||||||
void updatePosition(double elapsedTime);
|
void updatePosition(float elapsedTime);
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
Color m_color;
|
Color m_color;
|
||||||
|
@ -58,7 +58,7 @@ private:
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
Painter::CompositionMode m_compositionMode;
|
Painter::CompositionMode m_compositionMode;
|
||||||
float m_duration, m_ignorePhysicsAfter;
|
float m_duration, m_ignorePhysicsAfter;
|
||||||
double m_elapsedTime;
|
float m_elapsedTime;
|
||||||
bool m_finished;
|
bool m_finished;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ ParticleAffector::ParticleAffector()
|
||||||
m_elapsedTime = 0;
|
m_elapsedTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleAffector::update(double elapsedTime)
|
void ParticleAffector::update(float elapsedTime)
|
||||||
{
|
{
|
||||||
if(m_duration >= 0 && m_elapsedTime >= m_duration + m_delay) {
|
if(m_duration >= 0 && m_elapsedTime >= m_duration + m_delay) {
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
|
@ -94,7 +94,7 @@ bool GravityAffector::load(const OTMLNodePtr& node)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GravityAffector::updateParticle(const ParticlePtr& particle, double elapsedTime)
|
void GravityAffector::updateParticle(const ParticlePtr& particle, float elapsedTime)
|
||||||
{
|
{
|
||||||
if(!m_active)
|
if(!m_active)
|
||||||
return;
|
return;
|
||||||
|
@ -126,7 +126,7 @@ bool AttractionAffector::load(const OTMLNodePtr& node)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttractionAffector::updateParticle(const ParticlePtr& particle, double elapsedTime)
|
void AttractionAffector::updateParticle(const ParticlePtr& particle, float elapsedTime)
|
||||||
{
|
{
|
||||||
if(!m_active)
|
if(!m_active)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -30,22 +30,22 @@ class ParticleAffector {
|
||||||
public:
|
public:
|
||||||
ParticleAffector();
|
ParticleAffector();
|
||||||
|
|
||||||
void update(double elapsedTime);
|
void update(float elapsedTime);
|
||||||
virtual bool load(const OTMLNodePtr& node);
|
virtual bool load(const OTMLNodePtr& node);
|
||||||
virtual void updateParticle(const ParticlePtr&, double) {}
|
virtual void updateParticle(const ParticlePtr&, float) {}
|
||||||
|
|
||||||
bool hasFinished() { return m_finished; }
|
bool hasFinished() { return m_finished; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_finished, m_active;
|
bool m_finished, m_active;
|
||||||
float m_delay, m_duration;
|
float m_delay, m_duration;
|
||||||
double m_elapsedTime;
|
float m_elapsedTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GravityAffector : public ParticleAffector {
|
class GravityAffector : public ParticleAffector {
|
||||||
public:
|
public:
|
||||||
bool load(const OTMLNodePtr& node);
|
bool load(const OTMLNodePtr& node);
|
||||||
void updateParticle(const ParticlePtr& particle, double elapsedTime);
|
void updateParticle(const ParticlePtr& particle, float elapsedTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_angle, m_gravity;
|
float m_angle, m_gravity;
|
||||||
|
@ -54,7 +54,7 @@ private:
|
||||||
class AttractionAffector : public ParticleAffector {
|
class AttractionAffector : public ParticleAffector {
|
||||||
public:
|
public:
|
||||||
bool load(const OTMLNodePtr& node);
|
bool load(const OTMLNodePtr& node);
|
||||||
void updateParticle(const ParticlePtr& particle, double elapsedTime);
|
void updateParticle(const ParticlePtr& particle, float elapsedTime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Point m_position;
|
Point m_position;
|
||||||
|
|
|
@ -180,7 +180,7 @@ bool ParticleEmitter::load(const OTMLNodePtr& node)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParticleEmitter::update(double elapsedTime)
|
void ParticleEmitter::update(float elapsedTime)
|
||||||
{
|
{
|
||||||
// check if finished
|
// check if finished
|
||||||
if(m_duration >= 0 && m_elapsedTime >= m_duration + m_delay) {
|
if(m_duration >= 0 && m_elapsedTime >= m_duration + m_delay) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
bool load(const OTMLNodePtr& node);
|
bool load(const OTMLNodePtr& node);
|
||||||
|
|
||||||
void update(double elapsedTime);
|
void update(float elapsedTime);
|
||||||
|
|
||||||
bool hasFinished() { return m_finished; }
|
bool hasFinished() { return m_finished; }
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ private:
|
||||||
// self related
|
// self related
|
||||||
Point m_position;
|
Point m_position;
|
||||||
float m_duration, m_delay;
|
float m_duration, m_delay;
|
||||||
double m_elapsedTime;
|
float m_elapsedTime;
|
||||||
bool m_finished, m_active;
|
bool m_finished, m_active;
|
||||||
float m_burstRate;
|
float m_burstRate;
|
||||||
int m_currentBurst, m_burstCount;
|
int m_currentBurst, m_burstCount;
|
||||||
|
|
|
@ -70,7 +70,7 @@ void ParticleSystem::render()
|
||||||
|
|
||||||
void ParticleSystem::update()
|
void ParticleSystem::update()
|
||||||
{
|
{
|
||||||
static const double delay = 0.0166; // 60 updates/s
|
static const float delay = 0.0166; // 60 updates/s
|
||||||
|
|
||||||
// check if finished
|
// check if finished
|
||||||
if(m_particles.empty() && m_emitters.empty()) {
|
if(m_particles.empty() && m_emitters.empty()) {
|
||||||
|
@ -79,7 +79,7 @@ void ParticleSystem::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// check time
|
// check time
|
||||||
double elapsedTime = g_clock.timeElapsed(m_lastUpdateTime);
|
float elapsedTime = g_clock.timeElapsed(m_lastUpdateTime);
|
||||||
if(elapsedTime < delay)
|
if(elapsedTime < delay)
|
||||||
return;
|
return;
|
||||||
m_lastUpdateTime = g_clock.time() - std::fmod(elapsedTime, delay);
|
m_lastUpdateTime = g_clock.time() - std::fmod(elapsedTime, delay);
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_finished;
|
bool m_finished;
|
||||||
double m_lastUpdateTime;
|
float m_lastUpdateTime;
|
||||||
std::list<ParticlePtr> m_particles;
|
std::list<ParticlePtr> m_particles;
|
||||||
std::list<ParticleEmitterPtr> m_emitters;
|
std::list<ParticleEmitterPtr> m_emitters;
|
||||||
std::list<ParticleAffectorPtr> m_affectors;
|
std::list<ParticleAffectorPtr> m_affectors;
|
||||||
|
|
|
@ -116,7 +116,7 @@ bool luavalue_cast(int index, Color& color)
|
||||||
} else if(g_lua.isString()) {
|
} else if(g_lua.isString()) {
|
||||||
return Fw::cast(g_lua.toString(index), color);
|
return Fw::cast(g_lua.toString(index), color);
|
||||||
} else if(g_lua.isNil()) {
|
} else if(g_lua.isNil()) {
|
||||||
color = Fw::white;
|
color = Color::white;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "color.h"
|
||||||
|
|
||||||
|
// NOTE: AABBGGRR order
|
||||||
|
const Color Color::alpha = 0x00000000;
|
||||||
|
const Color Color::white = 0xffffffff;
|
||||||
|
const Color Color::black = 0xff000000;
|
||||||
|
const Color Color::red = 0xff0000ff;
|
||||||
|
const Color Color::darkRed = 0xff000080;
|
||||||
|
const Color Color::green = 0xff00ff00;
|
||||||
|
const Color Color::darkGreen = 0xff008000;
|
||||||
|
const Color Color::blue = 0xffff0000;
|
||||||
|
const Color Color::darkBlue = 0xff800000;
|
||||||
|
const Color Color::pink = 0xffff00ff;
|
||||||
|
const Color Color::darkPink = 0xff800080;
|
||||||
|
const Color Color::yellow = 0xff00ffff;
|
||||||
|
const Color Color::darkYellow = 0xff008080;
|
||||||
|
const Color Color::teal = 0xffffff00;
|
||||||
|
const Color Color::darkTeal = 0xff808000;
|
||||||
|
const Color Color::gray = 0xffa0a0a0;
|
||||||
|
const Color Color::darkGray = 0xff808080;
|
||||||
|
const Color Color::lightGray = 0xffc0c0c0;
|
||||||
|
const Color Color::orange = 0xffff8c00;
|
|
@ -76,6 +76,26 @@ public:
|
||||||
return Color(r, g, b);
|
return Color(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const Color alpha;
|
||||||
|
static const Color white;
|
||||||
|
static const Color black;
|
||||||
|
static const Color red;
|
||||||
|
static const Color darkRed;
|
||||||
|
static const Color green;
|
||||||
|
static const Color darkGreen;
|
||||||
|
static const Color blue;
|
||||||
|
static const Color darkBlue;
|
||||||
|
static const Color pink;
|
||||||
|
static const Color darkPink;
|
||||||
|
static const Color yellow;
|
||||||
|
static const Color darkYellow;
|
||||||
|
static const Color teal;
|
||||||
|
static const Color darkTeal;
|
||||||
|
static const Color gray;
|
||||||
|
static const Color darkGray;
|
||||||
|
static const Color lightGray;
|
||||||
|
static const Color orange;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float m_r;
|
float m_r;
|
||||||
float m_g;
|
float m_g;
|
||||||
|
@ -118,43 +138,43 @@ inline std::istream& operator>>(std::istream& in, Color& color)
|
||||||
in >> tmp;
|
in >> tmp;
|
||||||
|
|
||||||
if(tmp == "alpha") {
|
if(tmp == "alpha") {
|
||||||
color = Fw::alpha;
|
color = Color::alpha;
|
||||||
} else if(tmp == "black") {
|
} else if(tmp == "black") {
|
||||||
color = Fw::black;
|
color = Color::black;
|
||||||
} else if(tmp == "white") {
|
} else if(tmp == "white") {
|
||||||
color = Fw::white;
|
color = Color::white;
|
||||||
} else if(tmp == "red") {
|
} else if(tmp == "red") {
|
||||||
color = Fw::red;
|
color = Color::red;
|
||||||
} else if(tmp == "darkRed") {
|
} else if(tmp == "darkRed") {
|
||||||
color = Fw::darkRed;
|
color = Color::darkRed;
|
||||||
} else if(tmp == "green") {
|
} else if(tmp == "green") {
|
||||||
color = Fw::green;
|
color = Color::green;
|
||||||
} else if(tmp == "darkGreen") {
|
} else if(tmp == "darkGreen") {
|
||||||
color = Fw::darkGreen;
|
color = Color::darkGreen;
|
||||||
} else if(tmp == "blue") {
|
} else if(tmp == "blue") {
|
||||||
color = Fw::blue;
|
color = Color::blue;
|
||||||
} else if(tmp == "darkBlue") {
|
} else if(tmp == "darkBlue") {
|
||||||
color = Fw::darkBlue;
|
color = Color::darkBlue;
|
||||||
} else if(tmp == "pink") {
|
} else if(tmp == "pink") {
|
||||||
color = Fw::pink;
|
color = Color::pink;
|
||||||
} else if(tmp == "darkPink") {
|
} else if(tmp == "darkPink") {
|
||||||
color = Fw::darkPink;
|
color = Color::darkPink;
|
||||||
} else if(tmp == "yellow") {
|
} else if(tmp == "yellow") {
|
||||||
color = Fw::yellow;
|
color = Color::yellow;
|
||||||
} else if(tmp == "darkYellow") {
|
} else if(tmp == "darkYellow") {
|
||||||
color = Fw::darkYellow;
|
color = Color::darkYellow;
|
||||||
} else if(tmp == "teal") {
|
} else if(tmp == "teal") {
|
||||||
color = Fw::teal;
|
color = Color::teal;
|
||||||
} else if(tmp == "darkTeal") {
|
} else if(tmp == "darkTeal") {
|
||||||
color = Fw::darkTeal;
|
color = Color::darkTeal;
|
||||||
} else if(tmp == "gray") {
|
} else if(tmp == "gray") {
|
||||||
color = Fw::gray;
|
color = Color::gray;
|
||||||
} else if(tmp == "darkGray") {
|
} else if(tmp == "darkGray") {
|
||||||
color = Fw::darkGray;
|
color = Color::darkGray;
|
||||||
} else if(tmp == "lightGray") {
|
} else if(tmp == "lightGray") {
|
||||||
color = Fw::lightGray;
|
color = Color::lightGray;
|
||||||
} else if(tmp == "orange") {
|
} else if(tmp == "orange") {
|
||||||
color = Fw::orange;
|
color = Color::orange;
|
||||||
} else {
|
} else {
|
||||||
in.seekg(-tmp.length(), ios_base::cur);
|
in.seekg(-tmp.length(), ios_base::cur);
|
||||||
}
|
}
|
||||||
|
|
|
@ -646,9 +646,9 @@ void WIN32Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||||
uchar b = apng.pdata[i*4+2];
|
uchar b = apng.pdata[i*4+2];
|
||||||
uchar a = apng.pdata[i*4+3];
|
uchar a = apng.pdata[i*4+3];
|
||||||
Color color(r,g,b,a);
|
Color color(r,g,b,a);
|
||||||
if(color == Fw::white) { //white
|
if(color == Color::white) { //white
|
||||||
HSB_BIT_SET(xorMask, i);
|
HSB_BIT_SET(xorMask, i);
|
||||||
} else if(color == Fw::alpha) { //alpha
|
} else if(color == Color::alpha) { //alpha
|
||||||
HSB_BIT_SET(andMask, i);
|
HSB_BIT_SET(andMask, i);
|
||||||
} //otherwise black
|
} //otherwise black
|
||||||
}
|
}
|
||||||
|
|
|
@ -864,9 +864,9 @@ void X11Window::setMouseCursor(const std::string& file, const Point& hotSpot)
|
||||||
uchar b = apng.pdata[i*4+2];
|
uchar b = apng.pdata[i*4+2];
|
||||||
uchar a = apng.pdata[i*4+3];
|
uchar a = apng.pdata[i*4+3];
|
||||||
Color color(r,g,b,a);
|
Color color(r,g,b,a);
|
||||||
if(color == Fw::white) { //background
|
if(color == Color::white) { //background
|
||||||
LSB_BIT_SET(maskBits, i);
|
LSB_BIT_SET(maskBits, i);
|
||||||
} else if(color == Fw::black) { //foreground
|
} else if(color == Color::black) { //foreground
|
||||||
LSB_BIT_SET(mapBits, i);
|
LSB_BIT_SET(mapBits, i);
|
||||||
LSB_BIT_SET(maskBits, i);
|
LSB_BIT_SET(maskBits, i);
|
||||||
} //otherwise alpha
|
} //otherwise alpha
|
||||||
|
|
|
@ -47,7 +47,7 @@ void UIFrameCounter::draw()
|
||||||
}
|
}
|
||||||
m_frameCount++;
|
m_frameCount++;
|
||||||
|
|
||||||
m_font->renderText(m_fpsText, m_rect, m_align, Fw::white);
|
m_font->renderText(m_fpsText, m_rect, m_align, Color::white);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIFrameCounter::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
|
void UIFrameCounter::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
|
||||||
|
|
|
@ -60,7 +60,7 @@ void UIWidget::draw()
|
||||||
void UIWidget::drawSelf()
|
void UIWidget::drawSelf()
|
||||||
{
|
{
|
||||||
// draw style components in order
|
// draw style components in order
|
||||||
if(m_backgroundColor.a() > 0) {
|
if(m_backgroundColor.aF() != 0.0f) {
|
||||||
Rect backgroundDestRect = m_rect;
|
Rect backgroundDestRect = m_rect;
|
||||||
backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left);
|
backgroundDestRect.expand(-m_borderWidth.top, -m_borderWidth.right, -m_borderWidth.bottom, -m_borderWidth.left);
|
||||||
drawBackground(m_rect);
|
drawBackground(m_rect);
|
||||||
|
@ -92,10 +92,10 @@ void UIWidget::drawChildren()
|
||||||
|
|
||||||
// debug draw box
|
// debug draw box
|
||||||
if(g_ui.isDrawingDebugBoxes()) {
|
if(g_ui.isDrawingDebugBoxes()) {
|
||||||
g_painter.setColor(Fw::green);
|
g_painter.setColor(Color::green);
|
||||||
g_painter.drawBoundingRect(child->getRect());
|
g_painter.drawBoundingRect(child->getRect());
|
||||||
}
|
}
|
||||||
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Fw::red);
|
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Color::red);
|
||||||
|
|
||||||
g_painter.setOpacity(oldOpacity);
|
g_painter.setOpacity(oldOpacity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,10 @@
|
||||||
|
|
||||||
void UIWidget::initBaseStyle()
|
void UIWidget::initBaseStyle()
|
||||||
{
|
{
|
||||||
m_backgroundColor = Fw::alpha;
|
m_backgroundColor = Color::alpha;
|
||||||
m_borderColor.set(Fw::black);
|
m_borderColor.set(Color::black);
|
||||||
m_iconColor = Fw::white;
|
m_iconColor = Color::white;
|
||||||
m_color = Fw::white;
|
m_color = Color::white;
|
||||||
m_opacity = 1.0f;
|
m_opacity = 1.0f;
|
||||||
|
|
||||||
// generate an unique id, this is need because anchored layouts find widgets by id
|
// generate an unique id, this is need because anchored layouts find widgets by id
|
||||||
|
@ -312,7 +312,7 @@ void UIWidget::parseBaseStyle(const OTMLNodePtr& styleNode)
|
||||||
|
|
||||||
void UIWidget::drawBackground(const Rect& screenCoords)
|
void UIWidget::drawBackground(const Rect& screenCoords)
|
||||||
{
|
{
|
||||||
if(m_backgroundColor.a() > 0) {
|
if(m_backgroundColor.aF() != 0.0f) {
|
||||||
Rect drawRect = screenCoords;
|
Rect drawRect = screenCoords;
|
||||||
drawRect.translate(m_backgroundRect.topLeft());
|
drawRect.translate(m_backgroundRect.topLeft());
|
||||||
if(m_backgroundRect.isValid())
|
if(m_backgroundRect.isValid())
|
||||||
|
@ -325,28 +325,28 @@ void UIWidget::drawBackground(const Rect& screenCoords)
|
||||||
void UIWidget::drawBorder(const Rect& screenCoords)
|
void UIWidget::drawBorder(const Rect& screenCoords)
|
||||||
{
|
{
|
||||||
// top
|
// top
|
||||||
if(m_borderWidth.top > 0 && m_borderColor.top.a() > 0) {
|
if(m_borderWidth.top > 0 && m_borderColor.top.aF() != 0.0f) {
|
||||||
g_painter.setColor(m_borderColor.top);
|
g_painter.setColor(m_borderColor.top);
|
||||||
|
|
||||||
Rect borderRect(screenCoords.topLeft(), screenCoords.width(), m_borderWidth.top);
|
Rect borderRect(screenCoords.topLeft(), screenCoords.width(), m_borderWidth.top);
|
||||||
g_painter.drawFilledRect(borderRect);
|
g_painter.drawFilledRect(borderRect);
|
||||||
}
|
}
|
||||||
// right
|
// right
|
||||||
if(m_borderWidth.right > 0 && m_borderColor.right.a() > 0) {
|
if(m_borderWidth.right > 0 && m_borderColor.right.aF() != 0.0f) {
|
||||||
g_painter.setColor(m_borderColor.right);
|
g_painter.setColor(m_borderColor.right);
|
||||||
|
|
||||||
Rect borderRect(screenCoords.topRight() - Point(m_borderWidth.right - 1, 0), m_borderWidth.right, screenCoords.height());
|
Rect borderRect(screenCoords.topRight() - Point(m_borderWidth.right - 1, 0), m_borderWidth.right, screenCoords.height());
|
||||||
g_painter.drawFilledRect(borderRect);
|
g_painter.drawFilledRect(borderRect);
|
||||||
}
|
}
|
||||||
// bottom
|
// bottom
|
||||||
if(m_borderWidth.bottom > 0 && m_borderColor.bottom.a() > 0) {
|
if(m_borderWidth.bottom > 0 && m_borderColor.bottom.aF() != 0.0f) {
|
||||||
g_painter.setColor(m_borderColor.bottom);
|
g_painter.setColor(m_borderColor.bottom);
|
||||||
|
|
||||||
Rect borderRect(screenCoords.bottomLeft() - Point(0, m_borderWidth.bottom - 1), screenCoords.width(), m_borderWidth.bottom);
|
Rect borderRect(screenCoords.bottomLeft() - Point(0, m_borderWidth.bottom - 1), screenCoords.width(), m_borderWidth.bottom);
|
||||||
g_painter.drawFilledRect(borderRect);
|
g_painter.drawFilledRect(borderRect);
|
||||||
}
|
}
|
||||||
// left
|
// left
|
||||||
if(m_borderWidth.left > 0 && m_borderColor.left.a() > 0) {
|
if(m_borderWidth.left > 0 && m_borderColor.left.aF() != 0.0f) {
|
||||||
g_painter.setColor(m_borderColor.left);
|
g_painter.setColor(m_borderColor.left);
|
||||||
|
|
||||||
Rect borderRect(screenCoords.topLeft(), m_borderWidth.left, screenCoords.height());
|
Rect borderRect(screenCoords.topLeft(), m_borderWidth.left, screenCoords.height());
|
||||||
|
@ -356,7 +356,7 @@ void UIWidget::drawBorder(const Rect& screenCoords)
|
||||||
|
|
||||||
void UIWidget::drawIcon(const Rect& screenCoords)
|
void UIWidget::drawIcon(const Rect& screenCoords)
|
||||||
{
|
{
|
||||||
if(m_icon && m_iconColor.a() > 0) {
|
if(m_icon && m_iconColor.aF() != 0.0f) {
|
||||||
Rect drawRect;
|
Rect drawRect;
|
||||||
if(m_iconRect.isValid()) {
|
if(m_iconRect.isValid()) {
|
||||||
drawRect = screenCoords;
|
drawRect = screenCoords;
|
||||||
|
|
|
@ -70,7 +70,7 @@ void UIWidget::parseImageStyle(const OTMLNodePtr& styleNode)
|
||||||
|
|
||||||
void UIWidget::drawImage(const Rect& screenCoords)
|
void UIWidget::drawImage(const Rect& screenCoords)
|
||||||
{
|
{
|
||||||
if(!m_imageTexture || m_imageColor.a() == 0 || !screenCoords.isValid())
|
if(!m_imageTexture || m_imageColor.aF() == 0.0f || !screenCoords.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// cache vertex buffers
|
// cache vertex buffers
|
||||||
|
|
|
@ -48,7 +48,7 @@ void UIWidget::parseTextStyle(const OTMLNodePtr& styleNode)
|
||||||
|
|
||||||
void UIWidget::drawText(const Rect& screenCoords)
|
void UIWidget::drawText(const Rect& screenCoords)
|
||||||
{
|
{
|
||||||
if(m_text.length() == 0 || m_color.a() == 0)
|
if(m_text.length() == 0 || m_color.aF() == 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -66,7 +66,7 @@ void UIWidget::drawText(const Rect& screenCoords)
|
||||||
virtualTextRect.translate(m_textOffset);
|
virtualTextRect.translate(m_textOffset);
|
||||||
g_painter.saveAndResetState();
|
g_painter.saveAndResetState();
|
||||||
g_painter.setCompositionMode(Painter::CompositionMode_DestBlending);
|
g_painter.setCompositionMode(Painter::CompositionMode_DestBlending);
|
||||||
m_font->renderText(m_text, virtualTextRect, m_textAlign, Fw::white);
|
m_font->renderText(m_text, virtualTextRect, m_textAlign, Color::white);
|
||||||
g_painter.restoreSavedState();
|
g_painter.restoreSavedState();
|
||||||
m_textFramebuffer->release();
|
m_textFramebuffer->release();
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ void Creature::draw(const Point& dest, float scaleFactor, bool animate)
|
||||||
|
|
||||||
void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction)
|
void Creature::internalDrawOutfit(const Point& dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction)
|
||||||
{
|
{
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
if(!outfitProgram) {
|
if(!outfitProgram) {
|
||||||
outfitProgram = PainterShaderProgramPtr(new PainterShaderProgram);
|
outfitProgram = PainterShaderProgramPtr(new PainterShaderProgram);
|
||||||
outfitProgram->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader);
|
outfitProgram->addShaderFromSourceCode(Shader::Vertex, glslMainWithTexCoordsVertexShader + glslPositionOnlyVertexShader);
|
||||||
|
@ -225,7 +225,7 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
|
||||||
healthRect.setWidth((m_healthPercent / 100.0) * 25);
|
healthRect.setWidth((m_healthPercent / 100.0) * 25);
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
g_painter.setColor(Fw::black);
|
g_painter.setColor(Color::black);
|
||||||
g_painter.drawFilledRect(backgroundRect);
|
g_painter.drawFilledRect(backgroundRect);
|
||||||
|
|
||||||
g_painter.setColor(fillColor);
|
g_painter.setColor(fillColor);
|
||||||
|
@ -235,15 +235,15 @@ void Creature::drawInformation(const Point& point, bool useGray, const Rect& par
|
||||||
m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor);
|
m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor);
|
||||||
|
|
||||||
if(m_skull != Otc::SkullNone && m_skullTexture) {
|
if(m_skull != Otc::SkullNone && m_skullTexture) {
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
g_painter.drawTexturedRect(Rect(point.x + 12, point.y + 5, m_skullTexture->getSize()), m_skullTexture);
|
g_painter.drawTexturedRect(Rect(point.x + 12, point.y + 5, m_skullTexture->getSize()), m_skullTexture);
|
||||||
}
|
}
|
||||||
if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) {
|
if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) {
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
g_painter.drawTexturedRect(Rect(point.x, point.y + 5, m_shieldTexture->getSize()), m_shieldTexture);
|
g_painter.drawTexturedRect(Rect(point.x, point.y + 5, m_shieldTexture->getSize()), m_shieldTexture);
|
||||||
}
|
}
|
||||||
if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
|
if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
g_painter.drawTexturedRect(Rect(point.x + 12, point.y + 16, m_emblemTexture->getSize()), m_emblemTexture);
|
g_painter.drawTexturedRect(Rect(point.x + 12, point.y + 16, m_emblemTexture->getSize()), m_emblemTexture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ void Creature::setName(const std::string& name)
|
||||||
|
|
||||||
void Creature::setHealthPercent(uint8 healthPercent)
|
void Creature::setHealthPercent(uint8 healthPercent)
|
||||||
{
|
{
|
||||||
m_informationColor = Fw::black;
|
m_informationColor = Color::black;
|
||||||
|
|
||||||
if(healthPercent > 92) {
|
if(healthPercent > 92) {
|
||||||
m_informationColor.setGreen(188);
|
m_informationColor.setGreen(188);
|
||||||
|
|
|
@ -887,7 +887,7 @@ void Game::setAttackingCreature(const CreaturePtr& creature)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(creature) {
|
if(creature) {
|
||||||
creature->showStaticSquare(Fw::red);
|
creature->showStaticSquare(Color::red);
|
||||||
m_attackingCreature = creature;
|
m_attackingCreature = creature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ void Game::setFollowingCreature(const CreaturePtr& creature)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(creature) {
|
if(creature) {
|
||||||
creature->showStaticSquare(Fw::green);
|
creature->showStaticSquare(Color::green);
|
||||||
m_followingCreature = creature;
|
m_followingCreature = creature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ MapView::MapView()
|
||||||
std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_HEIGHT));
|
std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_HEIGHT));
|
||||||
|
|
||||||
m_framebuffer = FrameBufferPtr(new FrameBuffer(frameBufferSize));
|
m_framebuffer = FrameBufferPtr(new FrameBuffer(frameBufferSize));
|
||||||
m_framebuffer->setClearColor(Fw::black);
|
m_framebuffer->setClearColor(Color::black);
|
||||||
setVisibleDimension(Size(15, 11));
|
setVisibleDimension(Size(15, 11));
|
||||||
|
|
||||||
m_shaderProgram = PainterShaderProgramPtr(new PainterShaderProgram);
|
m_shaderProgram = PainterShaderProgramPtr(new PainterShaderProgram);
|
||||||
|
@ -106,7 +106,7 @@ void MapView::draw(const Rect& rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
g_painter.setCustomProgram(m_shaderProgram);
|
g_painter.setCustomProgram(m_shaderProgram);
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
|
|
||||||
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize;
|
Point drawOffset = ((m_drawDimension - m_visibleDimension - Size(1,1)).toPoint()/2) * m_tileSize;
|
||||||
if(m_followingCreature)
|
if(m_followingCreature)
|
||||||
|
@ -175,7 +175,7 @@ void MapView::draw(const Rect& rect)
|
||||||
Rect hRect(0, 0, 10, 2);
|
Rect hRect(0, 0, 10, 2);
|
||||||
vRect.moveCenter(rect.center());
|
vRect.moveCenter(rect.center());
|
||||||
hRect.moveCenter(rect.center());
|
hRect.moveCenter(rect.center());
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
g_painter.drawFilledRect(vRect);
|
g_painter.drawFilledRect(vRect);
|
||||||
g_painter.drawFilledRect(hRect);
|
g_painter.drawFilledRect(hRect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void Thing::internalDraw(const Point& dest, float scaleFactor, int w, int h, int
|
||||||
int spriteId = getSpriteId(w, h, layer, xPattern, yPattern, zPattern, animationPhase);
|
int spriteId = getSpriteId(w, h, layer, xPattern, yPattern, zPattern, animationPhase);
|
||||||
if(spriteId) {
|
if(spriteId) {
|
||||||
Rect drawRect(dest - getDisplacement()*scaleFactor, Size(scaledSize, scaledSize));
|
Rect drawRect(dest - getDisplacement()*scaleFactor, Size(scaledSize, scaledSize));
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
g_painter.drawTexturedRect(drawRect, g_sprites.getSpriteTexture(spriteId));
|
g_painter.drawTexturedRect(drawRect, g_sprites.getSpriteTexture(spriteId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ void UICreature::draw()
|
||||||
drawSelf();
|
drawSelf();
|
||||||
|
|
||||||
if(m_creature) {
|
if(m_creature) {
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
Rect drawRect = getChildrenRect();
|
Rect drawRect = getChildrenRect();
|
||||||
m_creature->drawOutfit(drawRect, !m_fixedCreatureSize);
|
m_creature->drawOutfit(drawRect, !m_fixedCreatureSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void UIItem::draw()
|
||||||
if(m_item) {
|
if(m_item) {
|
||||||
Point topLeft = m_rect.bottomRight() - Point(32, 32) + Point(m_padding.left, m_padding.top);
|
Point topLeft = m_rect.bottomRight() - Point(32, 32) + Point(m_padding.left, m_padding.top);
|
||||||
|
|
||||||
g_painter.setColor(Fw::white);
|
g_painter.setColor(Color::white);
|
||||||
m_item->draw(topLeft, 1, true);
|
m_item->draw(topLeft, 1, true);
|
||||||
|
|
||||||
if(m_font && m_item->isStackable() && m_item->getCount() > 1) {
|
if(m_font && m_item->isStackable() && m_item->getCount() > 1) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ void UIMap::draw()
|
||||||
drawSelf();
|
drawSelf();
|
||||||
|
|
||||||
// draw map border
|
// draw map border
|
||||||
g_painter.setColor(Fw::black);
|
g_painter.setColor(Color::black);
|
||||||
g_painter.drawBoundingRect(m_mapRect.expanded(1));
|
g_painter.drawBoundingRect(m_mapRect.expanded(1));
|
||||||
|
|
||||||
m_mapView->draw(m_mapRect);
|
m_mapView->draw(m_mapRect);
|
||||||
|
|
Loading…
Reference in New Issue