add style for colorbox in outfit window

master
Eduardo Bart 13 years ago
parent c999a49dc7
commit ba62863ff7

@ -17,7 +17,7 @@ Checkout our website at {http://otclient.info}[http://otclient.info/] for tutori
== Need help? == Need help?
If you have any questions or are looking for more information, please feel free to ask on our official If you have any questions or are looking for more information, please feel free to ask on our official
forum at http://otclient.info/ forum at http://otclient.info
== Bugs == Bugs

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

@ -31,3 +31,18 @@ CheckBox < UICheckBox
$disabled: $disabled:
background-color: #ffffff88 background-color: #ffffff88
color: #aaaaaa88 color: #aaaaaa88
ColorBox < UICheckBox
size: 16 16
box-size: 16 16
background-color: #ffffffff
$checked:
image:
source: /core_styles/images/colorbox.png
coords: 16 0 16 16
$!checked:
image:
source: /core_styles/images/colorbox.png
coords: 0 0 16 16

@ -78,8 +78,8 @@ function Outfit.create(creature, outfitList)
color:setStyle('Color') color:setStyle('Color')
color:setBackgroundColor(outfitColor) color:setBackgroundColor(outfitColor)
color:setMarginTop(j * 3 + j * 12) color:setMarginTop(j * 3 + j * 14)
color:setMarginLeft(i * 3 + i * 12) color:setMarginLeft(i * 3 + i * 14)
end end
end end

@ -1,24 +1,16 @@
ColorCheckBox < UICheckBox
size: 12 12
box-size: 12 12
background-color: #ffffffff
image:
source: /core_styles/images/empty_rect.png
ColorFirst < UIWidget ColorFirst < UIWidget
id: color id: color
margin.left: 20 margin.left: 20
anchors.top: creature.top anchors.top: creature.top
anchors.left: creature.right anchors.left: creature.right
Color < ColorCheckBox Color < ColorBox
anchors.top: color.top anchors.top: color.top
anchors.left: color.right anchors.left: color.right
Window Window
title: Select Outfit title: Select Outfit
size: 420 280 size: 450 280
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

@ -163,13 +163,14 @@ bool luavalue_cast(int index, Rect& rect)
rect.setWidth(g_lua.popInteger()); rect.setWidth(g_lua.popInteger());
g_lua.getField("height", index); g_lua.getField("height", index);
rect.setHeight(g_lua.popInteger()); rect.setHeight(g_lua.popInteger());
return true;
} else if(g_lua.isString()) { } else if(g_lua.isString()) {
return Fw::cast(g_lua.toString(index), rect); return Fw::cast(g_lua.toString(index), rect);
} else if(g_lua.isNil()) { } else if(g_lua.isNil()) {
rect = Rect(); rect = Rect();
return true; return true;
} }
return true; return false;
} }
// point // point
@ -196,7 +197,7 @@ bool luavalue_cast(int index, Point& point)
point = Point(); point = Point();
return true; return true;
} }
return true; return false;
} }
// size // size
@ -223,7 +224,7 @@ bool luavalue_cast(int index, Size& size)
size = Size(); size = Size();
return true; return true;
} }
return true; return false;
} }
// otml nodes // otml nodes
@ -270,9 +271,9 @@ bool luavalue_cast(int index, OTMLNodePtr& node)
node->writeAt(cnodeName, g_lua.toString()); node->writeAt(cnodeName, g_lua.toString());
g_lua.pop(); g_lua.pop();
} }
} else return true;
return false; }
return true; return false;
} }
// object ptr // object ptr

@ -48,7 +48,7 @@ void UICheckBox::render()
void UICheckBox::onMouseRelease(const Point& mousePos, Fw::MouseButton button) void UICheckBox::onMouseRelease(const Point& mousePos, Fw::MouseButton button)
{ {
if(isPressed() && getRect().contains(mousePos)) if(isPressed() && getRect().contains(mousePos))
setState(Fw::CheckedState, !isChecked()); setChecked(!isChecked());
} }
void UICheckBox::onStyleApply(const OTMLNodePtr& styleNode) void UICheckBox::onStyleApply(const OTMLNodePtr& styleNode)
@ -68,3 +68,14 @@ void UICheckBox::onStyleApply(const OTMLNodePtr& styleNode)
} }
} }
} }
bool UICheckBox::isChecked()
{
return hasState(Fw::CheckedState);
}
void UICheckBox::setChecked(bool checked)
{
if(setState(Fw::CheckedState, checked))
callLuaField("onCheckChange", checked);
}

@ -30,8 +30,8 @@ class UICheckBox : public UIWidget
public: public:
void render(); void render();
bool isChecked() { return hasState(Fw::CheckedState); } bool isChecked();
void setChecked(bool checked) { setState(Fw::CheckedState, checked); } void setChecked(bool checked);
void setText(const std::string& text) { m_text = text; } void setText(const std::string& text) { m_text = text; }
std::string getText() { return m_text; } std::string getText() { return m_text; }

@ -615,10 +615,10 @@ void UIWidget::updateLayout()
m_layout->update(); m_layout->update();
} }
void UIWidget::setState(Fw::WidgetState state, bool on) bool UIWidget::setState(Fw::WidgetState state, bool on)
{ {
if(state == Fw::InvalidState) if(state == Fw::InvalidState)
return; return false;
int oldStates = m_states; int oldStates = m_states;
if(on) if(on)
@ -626,8 +626,11 @@ void UIWidget::setState(Fw::WidgetState state, bool on)
else else
m_states &= ~state; m_states &= ~state;
if(oldStates != m_states) if(oldStates != m_states) {
updateStyle(); updateStyle();
return true;
}
return false;
} }
bool UIWidget::hasState(Fw::WidgetState state) bool UIWidget::hasState(Fw::WidgetState state)
@ -700,9 +703,7 @@ void UIWidget::updateState(Fw::WidgetState state)
child->updateState(state); child->updateState(state);
} }
if(newStatus != oldStatus) { if(setState(state, newStatus)) {
setState(state, newStatus);
if(state == Fw::FocusState) { if(state == Fw::FocusState) {
g_dispatcher.addEvent(std::bind(&UIWidget::onFocusChange, asUIWidget(), newStatus, m_lastFocusReason)); g_dispatcher.addEvent(std::bind(&UIWidget::onFocusChange, asUIWidget(), newStatus, m_lastFocusReason));
} else if(state == Fw::HoverState) } else if(state == Fw::HoverState)

@ -149,7 +149,7 @@ public:
void updateStates(); void updateStates();
virtual void updateState(Fw::WidgetState state); virtual void updateState(Fw::WidgetState state);
void setState(Fw::WidgetState state, bool on); bool setState(Fw::WidgetState state, bool on);
bool hasState(Fw::WidgetState state); bool hasState(Fw::WidgetState state);
void updateStyle(); void updateStyle();

@ -39,6 +39,9 @@
#include <otclient/ui/uimap.h> #include <otclient/ui/uimap.h>
#include <otclient/core/outfit.h> #include <otclient/core/outfit.h>
void push_luavalue(const Outfit& outfit);
bool luavalue_cast(int index, Outfit& outfit);
void OTClient::registerLuaFunctions() void OTClient::registerLuaFunctions()
{ {
g_lua.bindGlobalFunction("exit", std::bind(&OTClient::exit, &g_client)); g_lua.bindGlobalFunction("exit", std::bind(&OTClient::exit, &g_client));
@ -90,3 +93,40 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3));
#endif #endif
} }
void push_luavalue(const Outfit& outfit)
{
g_lua.newTable();
g_lua.pushInteger(outfit.getType());
g_lua.setField("type");
g_lua.pushInteger(outfit.getAddons());
g_lua.setField("addons");
g_lua.pushInteger(outfit.getHead());
g_lua.setField("head");
g_lua.pushInteger(outfit.getBody());
g_lua.setField("body");
g_lua.pushInteger(outfit.getLegs());
g_lua.setField("legs");
g_lua.pushInteger(outfit.getFeet());
g_lua.setField("feet");
}
bool luavalue_cast(int index, Outfit& outfit)
{
if(g_lua.isTable(index)) {
g_lua.getField("type", index);
outfit.setType(g_lua.popInteger());
g_lua.getField("addons", index);
outfit.setAddons(g_lua.popInteger());
g_lua.getField("head", index);
outfit.setHead(g_lua.popInteger());
g_lua.getField("body", index);
outfit.setBody(g_lua.popInteger());
g_lua.getField("legs", index);
outfit.setLegs(g_lua.popInteger());
g_lua.getField("feet", index);
outfit.setFeet(g_lua.popInteger());
return true;
}
return false;
}

Loading…
Cancel
Save