скрытие магазина и механизм удаления гильдий
This commit is contained in:
@@ -87,7 +87,14 @@ end
|
||||
|
||||
local StoreHandler = AIO.AddHandlers("STORE_CLIENT", {})
|
||||
|
||||
function StoreHandler.FrameData(player, services, links, nav, currencies, rank)
|
||||
function StoreHandler.FrameData(player, storeEnabled, services, links, nav, currencies, rank)
|
||||
SHOP_UI["Vars"].storeEnabled = storeEnabled == 1
|
||||
SHOP_UI.StoreAvailability_Update()
|
||||
|
||||
if not SHOP_UI["Vars"].storeEnabled then
|
||||
return
|
||||
end
|
||||
|
||||
SHOP_UI["Data"].services = services
|
||||
SHOP_UI["Data"].links = links
|
||||
SHOP_UI["Data"].nav = nav
|
||||
@@ -113,6 +120,7 @@ SHOP_UI = {
|
||||
currentPage = 1,
|
||||
maxPages = 1,
|
||||
accountRank = 0,
|
||||
storeEnabled = false,
|
||||
["playerCurrencies"] = {}
|
||||
},
|
||||
["Data"] = {
|
||||
@@ -146,6 +154,12 @@ function SHOP_UI.MainFrame_Create()
|
||||
shopFrame.Title:SetShadowOffset(1, -1)
|
||||
shopFrame.Title:SetPoint("TOP", shopFrame, "TOP", 0, -3)
|
||||
shopFrame.Title:SetText("|cffedd100Лавка Лунной Жрицы|r")
|
||||
|
||||
shopFrame.UnavailableText = shopFrame:CreateFontString()
|
||||
shopFrame.UnavailableText:SetFont("Fonts\\FRIZQT__.TTF", 24, "OUTLINE")
|
||||
shopFrame.UnavailableText:SetShadowOffset(1, -1)
|
||||
shopFrame.UnavailableText:SetPoint("CENTER", shopFrame, "CENTER", 85, 0)
|
||||
shopFrame.UnavailableText:SetText("|cffedd100Извините, магазин ещё не работает|r")
|
||||
|
||||
-- create navigation button placeholders, pass parent as arg
|
||||
SHOP_UI.NavButtons_Create(shopFrame)
|
||||
@@ -189,6 +203,7 @@ function SHOP_UI.MainFrame_Create()
|
||||
shopFrame:SetScript(
|
||||
"OnShow",
|
||||
function()
|
||||
AIO.Handle("STORE_SERVER", "FrameData")
|
||||
AIO.Handle("STORE_SERVER", "UpdateCurrencies")
|
||||
PlaySound("AuctionWindowOpen", "Master")
|
||||
end
|
||||
@@ -207,6 +222,32 @@ function SHOP_UI.MainFrame_Create()
|
||||
tinsert(UISpecialFrames, shopFrame:GetName())
|
||||
|
||||
SHOP_UI["FRAME"] = shopFrame
|
||||
SHOP_UI.StoreAvailability_Update()
|
||||
end
|
||||
|
||||
function SHOP_UI.StoreAvailability_Update()
|
||||
local enabled = SHOP_UI["Vars"].storeEnabled
|
||||
|
||||
if SHOP_UI["FRAME"] and SHOP_UI["FRAME"].UnavailableText then
|
||||
if enabled then
|
||||
SHOP_UI["FRAME"].UnavailableText:Hide()
|
||||
else
|
||||
SHOP_UI["FRAME"].UnavailableText:Show()
|
||||
end
|
||||
end
|
||||
|
||||
for _, collectionName in pairs({"NAV_BUTTONS", "SERVICE_BUTTONS", "PAGING_ELEMENTS", "CURRENCY_BUTTONS"}) do
|
||||
local collection = SHOP_UI[collectionName]
|
||||
if collection and not enabled then
|
||||
for _, element in pairs(collection) do
|
||||
element:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if SHOP_UI["MODEL_FRAME"] and not enabled then
|
||||
SHOP_UI["MODEL_FRAME"]:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
-- create navigation button placeholders
|
||||
|
||||
@@ -15,7 +15,8 @@ local CONFIG = {
|
||||
tooHighLevel = "Уровень персонажа слишком высок",
|
||||
mailBody = "Благодарим за покупку в Лавке Лунной Жрицы!",
|
||||
-- The service name is prefixed to this message
|
||||
successfulPurchase = "Покупка успешно совершена!"
|
||||
successfulPurchase = "Покупка успешно совершена!",
|
||||
storeUnavailable = "Магазин пока не работает"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +61,31 @@ local KEYS = GetDataStructKeys();
|
||||
|
||||
local StoreHandler = AIO.AddHandlers("STORE_SERVER", {})
|
||||
|
||||
local function IsStoreEnabled()
|
||||
local query = WorldDBQuery("SELECT `enabled` FROM `store`.`store_config` WHERE `id` = 1 LIMIT 1;")
|
||||
return query and query:GetUInt32(0) == 1
|
||||
end
|
||||
|
||||
function StoreHandler.FrameData(player)
|
||||
AIO.Handle(player, "STORE_CLIENT", "FrameData", GetServiceData(), GetLinkData(), GetNavData(), GetCurrencyData(), player:GetGMRank())
|
||||
local enabled = IsStoreEnabled()
|
||||
AIO.Handle(
|
||||
player,
|
||||
"STORE_CLIENT",
|
||||
"FrameData",
|
||||
enabled and 1 or 0,
|
||||
enabled and GetServiceData() or {},
|
||||
enabled and GetLinkData() or {},
|
||||
enabled and GetNavData() or {},
|
||||
enabled and GetCurrencyData() or {},
|
||||
player:GetGMRank()
|
||||
)
|
||||
end
|
||||
|
||||
function StoreHandler.UpdateCurrencies(player)
|
||||
if not IsStoreEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local tmp = {}
|
||||
for currencyId, currency in pairs(GetCurrencyData()) do
|
||||
local val = 0
|
||||
@@ -87,6 +108,11 @@ function StoreHandler.UpdateCurrencies(player)
|
||||
end
|
||||
|
||||
function StoreHandler.Purchase(player, serviceId)
|
||||
if not IsStoreEnabled() then
|
||||
player:SendAreaTriggerMessage(CONFIG.strings.storeUnavailable)
|
||||
return
|
||||
end
|
||||
|
||||
local services = GetServiceData()
|
||||
|
||||
-- See if the requested service exists
|
||||
|
||||
Reference in New Issue
Block a user