change color constants

master
Eduardo Bart 13 years ago
parent 05edcc218d
commit fbabe6b3ed

@ -1,6 +1,6 @@
Button < UIButton
font: helvetica-11px-bold
background-color: #ffffff
background-color: white
color: #f0ad4dff
size: 106 24
border-image:

@ -4,5 +4,5 @@ Label < UILabel
LargerLabel < Label
font: helvetica-12px-bold
color: #ffffff
color: white

@ -2,7 +2,7 @@ Window < UIWindow
font: helvetica-12px-bold
size: 200 200
opacity: 255
background-color: #ffffff
background-color: white
head:
height: 20
border-image:

@ -23,18 +23,31 @@
#ifndef FRAMEWORK_CONST_H
#define FRAMEWORK_CONST_H
#include "util/color.h"
#include "util/types.h"
namespace Fw
{
const Color white (0xFF, 0xFF, 0xFF, 0xFF);
const Color black (0x00, 0x00, 0x00, 0xFF);
const Color alpha (0x00, 0x00, 0x00, 0x00);
const Color red (0xFF, 0x00, 0x00, 0xFF);
const Color green (0x00, 0xFF, 0x00, 0xFF);
const Color blue (0x00, 0x00, 0xFF, 0xFF);
const Color pink (0xFF, 0x00, 0xFF, 0xFF);
const Color yellow(0xFF, 0xFF, 0x00, 0xFF);
// 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
};
enum LogLevel {
LogDebug = 0,

@ -25,60 +25,52 @@
#include "types.h"
#include "tools.h"
union RGBA
{
bool operator==(const RGBA& otherRgba) const { return rgba == otherRgba.rgba; }
uint32 rgba;
struct{
uint8 r;
uint8 g;
uint8 b;
uint8 a;
};
};
#include "../const.h"
class Color
{
public:
Color() { color.rgba = 0; }
Color(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) {
setRGBA(r, g, b, a);
}
Color(const Color& other) : color(other.color) { }
Color(RGBA rgba) : color(rgba) { }
Color() : m_rgba(0) { }
Color(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : m_r(r), m_g(g), m_b(b), m_a(a) { }
Color(const Color& other) : m_rgba(other.m_rgba) { }
Color(uint32 rgba) : m_rgba(rgba) { }
uint8 a() const { return color.a; }
uint8 b() const { return color.b; }
uint8 g() const { return color.g; }
uint8 r() const { return color.r; }
uint8 a() const { return m_a; }
uint8 b() const { return m_b; }
uint8 g() const { return m_g; }
uint8 r() const { return m_r; }
RGBA rgba() const { return color; }
uint32 rgba() const { return m_rgba; }
const uint8* rgbaPtr() const { return (const uint8*)&color; }
const uint8* rgbaPtr() const { return (const uint8*)&m_rgba; }
void setRed(int r) { color.r = r; }
void setGreen(int g) { color.g = g; }
void setBlue(int b) { color.b = b; }
void setAlpha(int a) { color.a = a; }
void setRed(int r) { m_r = r; }
void setGreen(int g) { m_g = g; }
void setBlue(int b) { m_b = b; }
void setAlpha(int a) { m_a = a; }
void setRed(float r) { setRed(int(r*255.0f)); }
void setGreen(float g) { setGreen(int(g*255.0f)); }
void setBlue(float b) { setBlue(int(b*255.0f)); }
void setAlpha(float a) { setAlpha(int(a*255.0f)); }
void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { color.r = r; color.g = g; color.b = b; color.a = a; }
void setRGBA(uint32 rgba) { color.rgba = rgba; }
void setRGBA(int r, int g, int b, int a = 0xFF) { m_r = r; m_g = g; m_b = b; m_a = a; }
void setRGBA(uint32 rgba) { rgba = rgba; }
Color& operator=(const Color& other) { color = other.color; return *this; }
bool operator==(const Color& other) const { return other.color.rgba == color.rgba; }
bool operator!=(const Color& other) const { return other.color.rgba != color.rgba; }
Color& operator=(const Color& other) { m_rgba = other.m_rgba; return *this; }
bool operator==(const Color& other) const { return other.m_rgba == m_rgba; }
bool operator!=(const Color& other) const { return other.m_rgba != m_rgba; }
private:
RGBA color;
union {
uint32 m_rgba;
struct {
uint8 m_r;
uint8 m_g;
uint8 m_b;
uint8 m_a;
};
};
};
inline std::ostream& operator<<(std::ostream& out, const Color& color)
@ -96,9 +88,9 @@ inline std::ostream& operator<<(std::ostream& out, const Color& color)
inline std::istream& operator>>(std::istream& in, Color& color)
{
using namespace std;
std::string tmp;
if(in.get() == '#') {
std::string tmp;
in >> tmp;
if(tmp.length() == 6 || tmp.length() == 8) {
@ -111,6 +103,49 @@ inline std::istream& operator>>(std::istream& in, Color& color)
color.setAlpha(255);
} else
in.seekg(-tmp.length()-1, ios_base::cur);
} else {
in.unget();
in >> tmp;
if(tmp == "alpha") {
color = Fw::alpha;
} else if(tmp == "black") {
color = Fw::black;
} else if(tmp == "white") {
color = Fw::white;
} else if(tmp == "red") {
color = Fw::red;
} else if(tmp == "darkRed") {
color = Fw::darkRed;
} else if(tmp == "green") {
color = Fw::green;
} else if(tmp == "darkGreen") {
color = Fw::darkGreen;
} else if(tmp == "blue") {
color = Fw::blue;
} else if(tmp == "darkBlue") {
color = Fw::darkBlue;
} else if(tmp == "pink") {
color = Fw::pink;
} else if(tmp == "darkPink") {
color = Fw::darkPink;
} else if(tmp == "yellow") {
color = Fw::yellow;
} else if(tmp == "darkYellow") {
color = Fw::darkYellow;
} else if(tmp == "teal") {
color = Fw::teal;
} else if(tmp == "darkTeal") {
color = Fw::darkTeal;
} else if(tmp == "gray") {
color = Fw::gray;
} else if(tmp == "darkGray") {
color = Fw::darkGray;
} else if(tmp == "lightGray") {
color = Fw::lightGray;
} else {
in.seekg(-tmp.length(), ios_base::cur);
}
}
return in;
}

@ -0,0 +1,242 @@
/*
* Copyright (c) 2010-2011 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.
*/
#ifndef OTCLIENT_CONST_H
#define OTCLIENT_CONST_H
#include <framework/util/color.h>
namespace Otc
{
static const char* CipsoftPublicRSA = "1321277432058722840622950990822933849527763264961655079678763618"
"4334395343554449668205332383339435179772895415509701210392836078"
"6959821132214473291575712138800495033169914814069637740318278150"
"2907336840325241747827401343576296990629870233111328210165697754"
"88792221429527047321331896351555606801473202394175817";
static const char* OtservPublicRSA = "1091201329673994292788609605089955415282375029027981291234687579"
"3726629149257644633073969600111060390723088861007265581882535850"
"3429057592827629436413108566029093628212635953836686562675849720"
"6207862794310902180176810615217550567108238764764442605581471797"
"07119674283982419152118103759076030616683978566631413";
enum ThingAttributesGroup {
ThingNoGroup = 0,
ThingGroundGroup,
ThingContainerGroup,
ThingWeaponGroup,
ThingAmmunitionGroup,
ThingArmorGroup,
ThingRuneGroup,
ThingTeleportGroup,
ThingMagicFieldGroup,
ThingWriteableGroup,
ThingKeyGroup,
ThingSplashGroup,
ThingFluidGroup,
ThingDoorGroup,
ThingLastGroup
};
enum ThingType {
Item,
Creature,
Effect,
Shot
};
enum SpriteMask {
SpriteRedMask = 0,
SpriteGreenMask,
SpriteBlueMask,
SpriteYellowMask,
SpriteNoMask = 255
};
enum Direction {
North = 0,
East,
South,
West
};
enum SpeakClasses {
SpeakSay = 0x01, //normal talk
SpeakWhisper = 0x02, //whispering - #w text
SpeakYell = 0x03, //yelling - #y text
SpeakPrivatePlayerToNpc = 0x04, //Player-to-NPC speaking(NPCs channel)
SpeakPrivateNpcToPlayer = 0x05, //NPC-to-Player speaking
SpeakPrivate = 0x06, //Players speaking privately to players
SpeakChannelYellow = 0x07, //Yellow message in chat
SpeakChannelWhite = 0x08, //White message in chat
SpeakBroadcast = 0x09, //Broadcast a message - #b
SpeakChannelRed = 0x0A, //Talk red on chat - #c
SpeakPrivateRed = 0x0B, //Red private - @name@ text
SpeakChannelOrange = 0x0C, //Talk orange on text
SpeakMonsterSay = 0x0D, //Talk orange
SpeakMonsterYell = 0x0E //Yell orange
};
static const Color OutfitColors[] = {
Color(255,255,255),
Color(255,212,191),
Color(255,233,191),
Color(255,255,191),
Color(233,255,191),
Color(212,255,191),
Color(191,255,191),
Color(191,255,212),
Color(191,255,233),
Color(191,255,255),
Color(191,233,255),
Color(191,212,255),
Color(191,191,255),
Color(212,191,255),
Color(233,191,255),
Color(255,191,255),
Color(255,191,233),
Color(255,191,212),
Color(255,191,191),
Color(128,128,128),
Color(191,159,143),
Color(191,175,143),
Color(191,191,143),
Color(175,191,143),
Color(159,191,143),
Color(143,191,143),
Color(143,191,159),
Color(143,191,175),
Color(143,191,191),
Color(143,175,191),
Color(143,159,191),
Color(143,143,191),
Color(159,143,191),
Color(175,143,191),
Color(191,143,191),
Color(191,143,175),
Color(191,143,159),
Color(191,143,143),
Color(182,182,182),
Color(191,127,95),
Color(191,159,95),
Color(191,191,95),
Color(159,191,95),
Color(127,191,95),
Color(95,191,95),
Color(95,191,127),
Color(95,191,159),
Color(95,191,191),
Color(95,159,191),
Color(95,127,191),
Color(95,95,191),
Color(127,95,191),
Color(159,95,191),
Color(191,95,191),
Color(191,95,159),
Color(191,95,127),
Color(191,95,95),
Color(145,145,145),
Color(191,106,63),
Color(191,148,63),
Color(191,191,63),
Color(148,191,63),
Color(107,191,63),
Color(63,191,63),
Color(63,191,106),
Color(63,191,148),
Color(63,191,191),
Color(63,148,191),
Color(63,106,191),
Color(63,63,191),
Color(106,63,191),
Color(148,63,191),
Color(191,63,191),
Color(191,63,148),
Color(191,63,106),
Color(191,63,63),
Color(109,109,109),
Color(255,85,0),
Color(255,170,0),
Color(255,255,0),
Color(170,255,0),
Color(84,255,0),
Color(0,255,0),
Color(0,255,84),
Color(0,255,170),
Color(0,255,255),
Color(0,169,255),
Color(0,85,255),
Color(0,0,255),
Color(85,0,255),
Color(169,0,255),
Color(254,0,255),
Color(255,0,170),
Color(255,0,85),
Color(255,0,0),
Color(72,72,72),
Color(191,63,0),
Color(191,127,0),
Color(191,191,0),
Color(127,191,0),
Color(63,191,0),
Color(0,191,0),
Color(0,191,63),
Color(0,191,127),
Color(0,191,191),
Color(0,127,191),
Color(0,63,191),
Color(0,0,191),
Color(63,0,191),
Color(127,0,191),
Color(191,0,191),
Color(191,0,127),
Color(191,0,63),
Color(191,0,0),
Color(36,36,36),
Color(127,42,0),
Color(127,85,0),
Color(127,127,0),
Color(85,127,0),
Color(42,127,0),
Color(0,127,0),
Color(0,127,42),
Color(0,127,85),
Color(0,127,127),
Color(0,84,127),
Color(0,42,127),
Color(0,0,127),
Color(42,0,127),
Color(84,0,127),
Color(127,0,127),
Color(191,0,85),
Color(127,0,42),
Color(127,0,0)
};
}
#endif

@ -183,9 +183,6 @@ void Creature::drawInformation(int x, int y, bool useGray)
g_graphics.bindColor(fillColor);
g_graphics.drawFilledRect(healthRect);
// restore white color
g_graphics.bindColor(Fw::white);
// name
FontPtr font = g_fonts.getFont("tibia-12px-rounded");
font->renderText(m_name, Rect(x-100, y-15, 200, 15), Fw::AlignTopCenter, fillColor);

@ -119,16 +119,16 @@ TexturePtr SpriteManager::loadSpriteMask(TexturePtr spriteTex, Otc::SpriteMask m
{
auto pixels = spriteTex->getPixels();
static RGBA maskColors[4] = { Fw::red.rgba(), Fw::green.rgba(), Fw::blue.rgba(), Fw::yellow.rgba() };
RGBA maskColor = maskColors[mask];
RGBA whiteColor = Fw::white.rgba();
RGBA alphaColor = Fw::alpha.rgba();
static uint32 maskColors[4] = { Fw::red, Fw::green, Fw::blue, Fw::yellow };
uint32 maskColor = maskColors[mask];
uint32 whiteColor = Fw::white;
uint32 alphaColor = Fw::alpha;
// convert pixels
// masked color -> white color
// any other color -> alpha color
for(int i=0;i<4096;i+=4) {
RGBA& currentColor = *(RGBA*)&pixels[i];
uint32& currentColor = *(uint32*)&pixels[i];
if(currentColor == maskColor)
currentColor = whiteColor;
else

Loading…
Cancel
Save