diff --git a/modules/outfit/outfit.lua b/modules/outfit/outfit.lua index d0bbb03b..88df051c 100644 --- a/modules/outfit/outfit.lua +++ b/modules/outfit/outfit.lua @@ -5,6 +5,46 @@ local window = nil local outfits = nil local currentOutfit = 1 +-- private functions +local function update() + local creatureWidget = window:getChildById('creature') + creatureWidget:setOutfitType(outfits[currentOutfit][1]) + + local nameWidget = window:getChildById('name') + nameWidget:setText(outfits[currentOutfit][2]) + + local availableAddons = outfits[currentOutfit][3] + local addon1 = window:getChildById('addon1') + local addon2 = window:getChildById('addon2') + local addon3 = window:getChildById('addon3') + addon1:setChecked(false) + addon2:setChecked(false) + addon3:setChecked(false) + + -- Maybe rework this someday + if availableAddons == 1 then + addon1:setChecked(true) + elseif availableAddons == 2 then + addon2:setChecked(true) + elseif availableAddons == 3 then + addon1:setChecked(true) + addon2:setChecked(true) + elseif availableAddons == 4 then + addon3:setChecked(true) + elseif availableAddons == 5 then + addon1:setChecked(true) + addon3:setChecked(true) + elseif availableAddons == 6 then + addon2:setChecked(true) + addon3:setChecked(true) + elseif availableAddons == 7 then + addon1:setChecked(true) + addon2:setChecked(true) + addon3:setChecked(true) + end + +end + -- public functions function Outfit.test() local button = UIButton.create() @@ -25,8 +65,27 @@ function Outfit.create(creature, outfitList) local creatureWidget = window:getChildById('creature') creatureWidget:setCreature(creature) + local firstColor = UIWidget.create() + window:addChild(firstColor) + firstColor:setStyle('ColorFirst') + + for i=0,18 do + for j=0,6 do + local color = UICheckBox.create() + window:addChild(color) + + local outfitColor = getOufitColor(j*19 + i) + + color:setStyle('Color') + color:setBackgroundColor(outfitColor) + color:setMarginTop(j * 3 + j * 12) + color:setMarginLeft(i * 3 + i * 12) + end + end + outfits = outfitList currentOutfit = 1 + update() end function Outfit.destroy() @@ -37,31 +96,26 @@ function Outfit.destroy() end function Outfit.nextType() - local creatureWidget = window:getChildById('creature') + currentOutfit = currentOutfit + 1 if currentOutfit > #outfits then currentOutfit = 1 end - creatureWidget:setOutfitType(outfits[currentOutfit][1]) + update() - -- TODO: update addons end function Outfit.previousType() - local creatureWidget = window:getChildById('creature') currentOutfit = currentOutfit - 1 if currentOutfit <= 0 then currentOutfit = #outfits end - creatureWidget:setOutfitType(outfits[currentOutfit][1]) + update() - -- TODO: update addons end --- private functions - -- hooked events connect(Game, { onOpenOutfitWindow = Outfit.create, diff --git a/modules/outfit/outfit.otui b/modules/outfit/outfit.otui index 8d4ed004..8e6f795f 100644 --- a/modules/outfit/outfit.otui +++ b/modules/outfit/outfit.otui @@ -1,6 +1,24 @@ +ColorCheckBox < UICheckBox + size: 12 12 + box-size: 12 12 + background-color: #ffffffff + + image: + source: /core_styles/images/empty_rect.png + +ColorFirst < UIWidget + id: color + margin.left: 20 + anchors.top: creature.top + anchors.left: creature.right + +Color < ColorCheckBox + anchors.top: color.top + anchors.left: color.right + Window title: Select Outfit - size: 256 320 + size: 420 280 anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter @@ -40,6 +58,7 @@ Window anchors.left: creature.left CheckBox + id: addon1 text: Addon 1 enabled: false margin.top: 10 @@ -48,6 +67,7 @@ Window anchors.left: prev.left CheckBox + id: addon2 text: Addon 2 enabled: false margin.top: 10 @@ -56,6 +76,7 @@ Window anchors.left: prev.left CheckBox + id: addon3 text: Addon 3 enabled: false margin.top: 10 diff --git a/src/framework/luascript/luafunctions.cpp b/src/framework/luascript/luafunctions.cpp index 8620f963..026720a8 100644 --- a/src/framework/luascript/luafunctions.cpp +++ b/src/framework/luascript/luafunctions.cpp @@ -132,6 +132,9 @@ void LuaInterface::registerFunctions() // UICheckBox g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create); + g_lua.bindClassMemberFunction("isChecked", &UICheckBox::isChecked); + g_lua.bindClassMemberFunction("setChecked", &UICheckBox::setChecked); + // UIWindow g_lua.registerClass(); diff --git a/src/otclient/otclientluafunctions.cpp b/src/otclient/otclientluafunctions.cpp index f9f00c6b..2c6596a0 100644 --- a/src/otclient/otclientluafunctions.cpp +++ b/src/otclient/otclientluafunctions.cpp @@ -37,6 +37,7 @@ #include #include #include +#include void OTClient::registerLuaFunctions() { @@ -44,6 +45,7 @@ void OTClient::registerLuaFunctions() g_lua.bindGlobalFunction("setOnClose", std::bind(&OTClient::setOnClose, &g_client, _1)); g_lua.bindGlobalFunction("importDat", std::bind(&ThingsType::load, &g_thingsType, _1)); g_lua.bindGlobalFunction("importSpr", std::bind(&SpriteManager::load, &g_sprites, _1)); + g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &ProtocolLogin::create);