Could you pass me the margins of the addons.otui file?
thanks for your answer. I managed to solve the margins using photophop graphics editor. When I put margin-left: 5 the pictures disappear from the box.Just slap a margin-left: 5 on each of those elements. Also it seems like the images are squished, you can check their size and then do size: W H to make them appear in their fully quality.
AddonButton < UIButton
width: 101
height: 125
margin-left: 5
margin-bottom: 5
Panel
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_assassin
anchors.top: parent.top
anchors.left: parent.left
@onClick: modules.game_shop.buyAssassin()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_barbarian
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBarbarian()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_beggar
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBeggar()
local shopWindow
local shopButton
local shopTabBar
local addonsPanel
local itemsPanel
local premiumPanel
local mountsPanel
local acceptWindow
function init()
shopWindow = g_ui.displayUI('shop')
shopWindow:hide()
shopTabBar = shopWindow:getChildById('shopTabBar')
shopTabBar:setContentWidget(shopWindow:getChildById('shopTabContent'))
addonsPanel = g_ui.loadUI('addons')
shopTabBar:addTab(tr('Addons'), addonsPanel, '/modules/game_shop/images/shoptabs/addons')
itemsPanel = g_ui.loadUI('items')
shopTabBar:addTab(tr('Items'), itemsPanel, '/modules/game_shop/images/shoptabs/items')
mountsPanel = g_ui.loadUI('mounts')
shopTabBar:addTab(tr('Mounts'), mountsPanel, '/modules/game_shop/images/shoptabs/mounts')
premiumPanel = g_ui.loadUI('premium')
shopTabBar:addTab(tr('Premium'), premiumPanel, '/modules/game_shop/images/shoptabs/premium')
shopButton = modules.client_topmenu.addLeftGameButton('shopButton', tr('Shop'), '/modules/game_shop/images/shop', toggle)
end
function terminate()
shopWindow:destroy()
shopButton:destroy()
end
function toggle()
if shopWindow:isVisible() then
hide()
else
show()
end
end
function show()
shopWindow:show()
shopWindow:raise()
shopWindow:focus()
end
function hide()
shopWindow:hide()
if acceptWindow then
acceptWindow:destroy()
acceptWindow = nil
end
end
function addTab(name, panel, icon)
shopTabBar:addTab(name, panel, icon)
end
function addButton(name, func, icon)
shopTabBar:addButton(name, func, icon)
end
-- Buy functions:
-- Addons Assassin
function buyAssassin()
if acceptWindow then
return true
end
local acceptFunc = function()
g_game.talk('!outfits assassinfull')
acceptWindow:destroy()
acceptWindow = nil
end
local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end
acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"),
{ { text=tr('Yes'), callback=acceptFunc },
{ text=tr('No'), callback=cancelFunc },
anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc)
return true
end
-- Addons Barbarian
function buyBarbarian()
if acceptWindow then
return true
end
local acceptFunc = function()
g_game.talk('!outfits barbarian')
acceptWindow:destroy()
acceptWindow = nil
end
local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end
acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"),
{ { text=tr('Yes'), callback=acceptFunc },
{ text=tr('No'), callback=cancelFunc },
anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc)
return true
end
-- Addons Beggar
function buyBeggar()
if acceptWindow then
return true
end
local acceptFunc = function()
g_game.talk('!outfits beggar')
acceptWindow:destroy()
acceptWindow = nil
end
local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end
acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"),
{ { text=tr('Yes'), callback=acceptFunc },
{ text=tr('No'), callback=cancelFunc },
anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc)
return true
end
margin-top: 5
margin-left: 5
margin-right: 5
margin-bottom: 5
anchors.left: parent.left
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.top: parent.top
anchors.left: prev.left
anchors.bottom: prev.bottom
anchors.right: prev.right
anchors.top: prev.top
thanks for your answer. I managed to solve the margins using photophop graphics editor. When I put margin-left: 5 the pictures disappear from the box.
I have another problem, when I try to add the fourth image, all the previous images disappear. I am doing something wrong? or do I need some code that I'm not using?
When I add the fourth image, it sends me back to the box without images above.
Here I leave the code used "Otui & Lua"
Code Otui:
CSS:AddonButton < UIButton width: 101 height: 125 Panel AddonButton image-source: /modules/game_shop/images/buttonimg/addon_assassin anchors.top: parent.top anchors.left: parent.left @onClick: modules.game_shop.buyAssassin() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_barbarian anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyBarbarian() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_beggar anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyBeggar()
Code Lua:
Lua:local shopWindow local shopButton local shopTabBar local addonsPanel local itemsPanel local premiumPanel local mountsPanel local acceptWindow function init() shopWindow = g_ui.displayUI('shop') shopWindow:hide() shopTabBar = shopWindow:getChildById('shopTabBar') shopTabBar:setContentWidget(shopWindow:getChildById('shopTabContent')) addonsPanel = g_ui.loadUI('addons') shopTabBar:addTab(tr('Addons'), addonsPanel, '/modules/game_shop/images/shoptabs/addons') itemsPanel = g_ui.loadUI('items') shopTabBar:addTab(tr('Items'), itemsPanel, '/modules/game_shop/images/shoptabs/items') mountsPanel = g_ui.loadUI('mounts') shopTabBar:addTab(tr('Mounts'), mountsPanel, '/modules/game_shop/images/shoptabs/mounts') premiumPanel = g_ui.loadUI('premium') shopTabBar:addTab(tr('Premium'), premiumPanel, '/modules/game_shop/images/shoptabs/premium') shopButton = modules.client_topmenu.addLeftGameButton('shopButton', tr('Shop'), '/modules/game_shop/images/shop', toggle) end function terminate() shopWindow:destroy() shopButton:destroy() end function toggle() if shopWindow:isVisible() then hide() else show() end end function show() shopWindow:show() shopWindow:raise() shopWindow:focus() end function hide() shopWindow:hide() if acceptWindow then acceptWindow:destroy() acceptWindow = nil end end function addTab(name, panel, icon) shopTabBar:addTab(name, panel, icon) end function addButton(name, func, icon) shopTabBar:addButton(name, func, icon) end -- Buy functions: -- Addons Assassin function buyAssassin() if acceptWindow then return true end local acceptFunc = function() g_game.talk('!outfits assassinfull') acceptWindow:destroy() acceptWindow = nil end local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"), { { text=tr('Yes'), callback=acceptFunc }, { text=tr('No'), callback=cancelFunc }, anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc) return true end -- Addons Barbarian function buyBarbarian() if acceptWindow then return true end local acceptFunc = function() g_game.talk('!outfits barbarian') acceptWindow:destroy() acceptWindow = nil end local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"), { { text=tr('Yes'), callback=acceptFunc }, { text=tr('No'), callback=cancelFunc }, anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc) return true end -- Addons Beggar function buyBeggar() if acceptWindow then return true end local acceptFunc = function() g_game.talk('!outfits beggar') acceptWindow:destroy() acceptWindow = nil end local cancelFunc = function() acceptWindow:destroy() acceptWindow = nil end acceptWindow = displayGeneralBox(tr('Accept transaction'), tr("Do you really want to buy this item?"), { { text=tr('Yes'), callback=acceptFunc }, { text=tr('No'), callback=cancelFunc }, anchor=AnchorHorizontalCenter }, acceptFunc, cancelFunc) return true end
How do I add the fourth image next to the third image without disappearing from the box? and how would the code be used to add the following below the first image.
I tried to play with these codes but they do not work for me or they just I dont add them correctly.
Could you support me?CSS:anchors.left: parent.left anchors.bottom: parent.bottom anchors.right: parent.right anchors.top: parent.top margin-top: 5 margin-left: 5 margin-right: 5 margin-bottom: 5 anchors.left: prev.left anchors.bottom: prev.bottom anchors.right: prev.right anchors.top: prev.top
Thanks for replying friend, I managed to get more images added to the box, but now I'm trying to add the new images in the bottom row, I have problems there. I will keep trying and if I can not solve it I will notify you to help me.
That's awesome mate.
If you wanna make a next row, the best thing would be like I suggested, to anchor a new box to this one, let's call it box1:
Now you would make a Box6 and give it anchor.top: box1.bottom and anchor.left: parent.left
Problem solved
AddonButton < UIButton
width: 101
height: 125
margin-left: 5
Panel
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_assassin
anchors.top: parent.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyAssassin()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_barbarian
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBarbarian()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_beggar
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBeggar()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_norseman
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyNorseman()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyPirate()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: parent.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyPirate()
I have a problem creating the box6, the box6 is created above the box1, and when moving with the mause the main window, the row above does not stay in the margins.
code otui:
Do you happen to have the list of variables to use in the "otui" file so I can play with the codes and try to learn more about its functionality?CSS:AddonButton < UIButton width: 101 height: 125 margin-left: 5 Panel AddonButton image-source: /modules/game_shop/images/buttonimg/addon_assassin anchors.top: parent.bottom anchors.left: parent.left @onClick: modules.game_shop.buyAssassin() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_barbarian anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyBarbarian() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_beggar anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyBeggar() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_norseman anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyNorseman() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_pirate anchors.top: prev.top anchors.left: prev.right @onClick: modules.game_shop.buyPirate() AddonButton image-source: /modules/game_shop/images/buttonimg/addon_pirate anchors.top: parent.bottom anchors.left: parent.left @onClick: modules.game_shop.buyPirate()
Edit:
solve the problem, now I have another problem xD
I move the window with the mause and the boxes do not stay fixed to the main window, they move leaving their margins!
AddonButton < UIButton
width: 101
height: 125
margin-left: 5
Panel
AddonButton
id: box1
image-source: /modules/game_shop/images/buttonimg/addon_assassin
anchors.top: parent.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyAssassin()
AddonButton
id: box2
image-source: /modules/game_shop/images/buttonimg/addon_barbarian
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBarbarian()
AddonButton
id: box3
image-source: /modules/game_shop/images/buttonimg/addon_beggar
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBeggar()
AddonButton
id: box4
image-source: /modules/game_shop/images/buttonimg/addon_norseman
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyNorseman()
AddonButton
id: box5
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyPirate()
AddonButton
id: box6
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: box1.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyPirate()
using your code appears as follows.That's because you broke the anchoring, try
You can find the stuff you need in luafunctions.cpp and uiwidgetbasestyle.cpp btw
AddonButton < UIButton
width: 101
height: 125
margin-left: 5
Panel
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_assassin
anchors.top: box1.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyAssassin()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_barbarian
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBarbarian()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_beggar
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBeggar()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_norseman
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyNorseman()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyPirate()
AddonButton
image-source: /modules/game_shop/images/buttonimg/addon_shaman
anchors.top: prev.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyShaman()
AddonButton < UIButton
width: 101
height: 125
margin-left: 5
Panel
AddonButton
id: box1
image-source: /modules/game_shop/images/buttonimg/addon_assassin
anchors.top: parent.top
anchors.left: parent.left
@onClick: modules.game_shop.buyAssassin()
AddonButton
id: box2
image-source: /modules/game_shop/images/buttonimg/addon_barbarian
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBarbarian()
AddonButton
id: box3
image-source: /modules/game_shop/images/buttonimg/addon_beggar
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyBeggar()
AddonButton
id: box4
image-source: /modules/game_shop/images/buttonimg/addon_norseman
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyNorseman()
AddonButton
id: box5
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: prev.top
anchors.left: prev.right
@onClick: modules.game_shop.buyPirate()
AddonButton
id: box6
image-source: /modules/game_shop/images/buttonimg/addon_pirate
anchors.top: box1.bottom
anchors.left: parent.left
@onClick: modules.game_shop.buyPirate()
you're a big friend now if it works correctlyYeah sorry, I didn't carefully review your code, there was a mistake, your box1 was anchored to the bottom of parent instead of top, fix that and it should work.
Hi, I think I want another style in my shop window.
my store currently:
my store as it should be.. edited in photoshop:
I hope to give a good idea of what I really want to do. if they can help me, it would be a great job.
ScrollablePanel
id: mainPanel
vertical-scrollbar: mainPanelScrollbar
//define more attributes here
VerticalScrollBar
id: mainPanelScrollbar
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.right: parent.right
step: 24
pixels-scroll: true
I do not really understand what you try to explain to me.Yeah you can do that easily. Change main parent container type from "Panel" to "ScrollablePanel", and attach a vertical scrollbar to it. Example of the 2:
Code:ScrollablePanel id: mainPanel vertical-scrollbar: mainPanelScrollbar //define more attributes here VerticalScrollBar id: mainPanelScrollbar anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right step: 24 pixels-scroll: true
You can apply the same to the list on the left side, then attach an UIWidget element with image-source: /path/to/pic for your "Store" image. Anchor its top to the bottom of this left scrollable panel.
Stingy wool. What do you not understand? It's simple, explained very well.I do not really understand what you try to explain to me.
Excuse me, but if this bothers you, you can go somewhere else.Stingy wool. What do you not understand? It's simple, explained very well.
Give something from yourself, gosh.
I do not really understand what you try to explain to me.
I explain myself a little better, I want to make the new window in this way as shown in the image.
what commands should I use to form the code and if I really have to do the writing of the OTUI file again?
function onSay(cid, words, param, channel)
local player = Player(cid)
local guid = player:getAccountId()
local points = db.asyncStoreQuery("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. guid)
if (player.points > 10) then
player:addItem(10135, 1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You only have " .. points .. " in your account")
end
end
I am using the shop system provided above. I am trying to create a talk action to communicate with my database:
Here is what i wrote, maybe someone here can tell me why it is throwing an error
Code:function onSay(cid, words, param, channel) local player = Player(cid) local guid = player:getAccountId() local points = db.asyncStoreQuery("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. guid) if (player.points > 10) then player:addItem(10135, 1) else player:sendTextMessage(MESSAGE_INFO_DESCR, "You only have " .. points .. " in your account") end end
Screenshot