-- Elo Changer local w = display.contentWidth local h = display.contentHeight local gg = display.newGroup() local men = display.newGroup() -- КНОПКА open local btn = display.newRoundedRect(gg, w - 90, 30, 100, 45, 12) btn:setFillColor(0.2,0.2,0.25) btn:setStrokeColor(1,0.5,0,1) btn.strokeWidth = 2 local btnText = display.newText("open", btn.x, btn.y, native.systemFontBold, 18) btnText:setFillColor(1,1,1) gg:insert(btnText) -- МЕНЮ local panelW = 520 local panelH = 620 local panel = display.newRoundedRect(men, display.contentCenterX, display.contentCenterY, panelW, panelH, 18) panel:setFillColor(0,0,0,0.96) panel:setStrokeColor(1,0.5,0,1) panel.strokeWidth = 2 local title = display.newText("Elo Changer", panel.x, panel.y - panelH/2 + 35, native.systemFontBold, 24) title:setFillColor(1,0.5,0) men:insert(title) local close = display.newText("×", panel.x + panelW/2 - 35, panel.y - panelH/2 + 35, native.systemFontBold, 32) close:setFillColor(1,0.4,0.4) men:insert(close) local lineTop = display.newLine(panel.x - panelW/2 + 20, panel.y - panelH/2 + 55, panel.x + panelW/2 - 20, panel.y - panelH/2 + 55) lineTop:setStrokeColor(1,0.5,0,0.5) lineTop.strokeWidth = 1 men:insert(lineTop) men.isVisible = false -- ПЕРЕТАСКИВАНИЕ КНОПКИ local btnDrag = false local btnStartX, btnStartY local function onBtnDrag(e) if e.phase == "began" then btnDrag = true btnStartX = e.x - gg.x btnStartY = e.y - gg.y elseif e.phase == "moved" and btnDrag then gg.x = e.x - btnStartX gg.y = e.y - btnStartY elseif e.phase == "ended" then btnDrag = false end return true end btn:addEventListener("touch", onBtnDrag) btnText:addEventListener("touch", onBtnDrag) -- ПЕРЕТАСКИВАНИЕ МЕНЮ local menuDrag = false local menuStartX, menuStartY local function onMenuDrag(e) if e.phase == "began" then menuDrag = true menuStartX = e.x - men.x menuStartY = e.y - men.y elseif e.phase == "moved" and menuDrag then men.x = e.x - menuStartX men.y = e.y - menuStartY elseif e.phase == "ended" then menuDrag = false end return true end panel:addEventListener("touch", onMenuDrag) title:addEventListener("touch", onMenuDrag) local function toggleMenu() men.isVisible = not men.isVisible btnText.text = men.isVisible and "close" or "open" end btn:addEventListener("tap", toggleMenu) btnText:addEventListener("tap", toggleMenu) close:addEventListener("tap", toggleMenu) -- ============ ОТОБРАЖЕНИЕ ТЕКУЩЕГО ЭЛО ============ local currentEloLabel = display.newText("Текущий ЭЛО:", panel.x, panel.y - panelH/2 + 100, native.systemFontBold, 20) currentEloLabel:setFillColor(1,1,1) men:insert(currentEloLabel) local currentEloValue = display.newText("0", panel.x, panel.y - panelH/2 + 135, native.systemFontBold, 32) currentEloValue:setFillColor(0.3,1,0.3) men:insert(currentEloValue) -- ============ ПОЛЕ ВВОДА (по центру) ============ local inputBg = display.newRoundedRect(men, panel.x, panel.y - panelH/2 + 190, 280, 50, 8) inputBg:setFillColor(0.2,0.2,0.25) inputBg:setStrokeColor(1,0.5,0,1) inputBg.strokeWidth = 2 men:insert(inputBg) local inputValue = display.newText("0", inputBg.x, inputBg.y, native.systemFontBold, 28) inputValue:setFillColor(1,1,1) men:insert(inputValue) -- ============ ЦИФРОВАЯ КЛАВИАТУРА (центрированная) ============ local keyW = 70 local keyH = 55 local spacing = 12 local keyboardRows = 4 local keyboardCols = 3 local keyboardWidth = keyboardCols * keyW + (keyboardCols - 1) * spacing local keyboardHeight = keyboardRows * keyH + (keyboardRows - 1) * spacing local startXkey = panel.x - keyboardWidth / 2 local startYkey = panel.y + panelH/2 - keyboardHeight - 40 local keys = { {"7", 0, 0}, {"8", 1, 0}, {"9", 2, 0}, {"4", 0, 1}, {"5", 1, 1}, {"6", 2, 1}, {"1", 0, 2}, {"2", 1, 2}, {"3", 2, 2}, {"0", 1, 3}, {"⌫", 2, 3}, {"✓", 0, 3} } local userNumber = 0 local function updateInputDisplay() inputValue.text = tostring(userNumber) end for i, key in ipairs(keys) do local col = key[2] local row = key[3] local x = startXkey + col * (keyW + spacing) + keyW/2 local y = startYkey + row * (keyH + spacing) + keyH/2 local kBtn = display.newRoundedRect(men, x, y, keyW, keyH, 10) kBtn:setFillColor(0.3,0.3,0.4) kBtn:setStrokeColor(1,0.5,0,1) kBtn.strokeWidth = 1 local kText = display.newText(key[1], x, y, native.systemFontBold, 24) kText:setFillColor(1,1,1) men:insert(kBtn) men:insert(kText) if key[1] == "⌫" then kBtn:addEventListener("tap", function() userNumber = math.floor(userNumber / 10) updateInputDisplay() end) elseif key[1] == "✓" then kBtn:addEventListener("tap", function() if TablaSettings then TablaSettings.elo = userNumber SalvaPrefs(TablaSettings) currentEloValue.text = tostring(userNumber) if LeaderboardMgr and LeaderboardMgr.submitElo then LeaderboardMgr.submitElo(userNumber) end print("[ELO] Установлено: " .. userNumber) end end) else local digit = tonumber(key[1]) kBtn:addEventListener("tap", function() userNumber = userNumber * 10 + digit if userNumber > 9999999 then userNumber = 9999999 end updateInputDisplay() end) end end -- ============ ОБНОВЛЕНИЕ ПРИ ОТКРЫТИИ ============ local function updateEloDisplay() if TablaSettings and TablaSettings.elo then currentEloValue.text = tostring(TablaSettings.elo) else currentEloValue.text = "0" end userNumber = TablaSettings and TablaSettings.elo or 0 updateInputDisplay() end updateEloDisplay() print("=================================") print("Elo Changer - ЦЕНТРИРОВАННАЯ КЛАВИАТУРА") print("Введите число, нажмите ✓") print("=================================")