mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
Version 0.95 BETA
This commit is contained in:
78
modules/client_feedback/feedback.lua
Normal file
78
modules/client_feedback/feedback.lua
Normal file
@@ -0,0 +1,78 @@
|
||||
local feedbackWindow
|
||||
local textEdit
|
||||
local okButton
|
||||
local cancelButton
|
||||
local postId = 0
|
||||
local tries = 0
|
||||
local replyEvent = nil
|
||||
|
||||
function init()
|
||||
feedbackWindow = g_ui.displayUI('feedback')
|
||||
feedbackWindow:hide()
|
||||
|
||||
textEdit = feedbackWindow:getChildById('text')
|
||||
okButton = feedbackWindow:getChildById('okButton')
|
||||
cancelButton = feedbackWindow:getChildById('cancelButton')
|
||||
|
||||
okButton.onClick = send
|
||||
cancelButton.onClick = hide
|
||||
feedbackWindow.onEscape = hide
|
||||
end
|
||||
|
||||
function terminate()
|
||||
feedbackWindow:destroy()
|
||||
removeEvent(replyEvent)
|
||||
end
|
||||
|
||||
function show()
|
||||
if Services.feedback == nil or Services.feedback:len() < 4 then
|
||||
return
|
||||
end
|
||||
|
||||
feedbackWindow:show()
|
||||
feedbackWindow:raise()
|
||||
feedbackWindow:focus()
|
||||
|
||||
textEdit:setMaxLength(8192)
|
||||
textEdit:setText('')
|
||||
textEdit:setEditable(true)
|
||||
textEdit:setCursorVisible(true)
|
||||
feedbackWindow:focusChild(textEdit, KeyboardFocusReason)
|
||||
|
||||
tries = 0
|
||||
end
|
||||
|
||||
function hide()
|
||||
feedbackWindow:hide()
|
||||
textEdit:setEditable(false)
|
||||
textEdit:setCursorVisible(false)
|
||||
end
|
||||
|
||||
function send()
|
||||
local text = textEdit:getText()
|
||||
if text:len() > 1 then
|
||||
local localPlayer = g_game.getLocalPlayer()
|
||||
local playerData = nil
|
||||
if localPlayer ~= nil then
|
||||
playerData = {
|
||||
name = localPlayer:getName(),
|
||||
position = localPlayer:getPosition()
|
||||
}
|
||||
end
|
||||
local data = json.encode({
|
||||
text = text,
|
||||
version = g_app.getVersion(),
|
||||
host = g_settings.get('host'),
|
||||
player = playerData
|
||||
})
|
||||
postId = HTTP.post(Services.feedback, data, function(ret, err)
|
||||
if err then
|
||||
tries = tries + 1
|
||||
if tries < 3 then
|
||||
replyEvent = scheduleEvent(send, 1000)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
hide()
|
||||
end
|
10
modules/client_feedback/feedback.otmod
Normal file
10
modules/client_feedback/feedback.otmod
Normal file
@@ -0,0 +1,10 @@
|
||||
Module
|
||||
name: client_feedback
|
||||
description: Allow to send feedback
|
||||
author: otclientv8
|
||||
website: otclient.ovh
|
||||
sandboxed: true
|
||||
dependencies: [ game_interface ]
|
||||
scripts: [ feedback ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
48
modules/client_feedback/feedback.otui
Normal file
48
modules/client_feedback/feedback.otui
Normal file
@@ -0,0 +1,48 @@
|
||||
MainWindow
|
||||
id: feedbackWindow
|
||||
size: 300 280
|
||||
!text: tr("Feedback/Bug report")
|
||||
|
||||
Label
|
||||
id: description
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
text-auto-resize: true
|
||||
text-align: left
|
||||
text-wrap: true
|
||||
!text: tr("Bellow enter your feedback or bug report. Please include as much details as possible.")
|
||||
|
||||
MultilineTextEdit
|
||||
id: text
|
||||
anchors.top: textScroll.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: textScroll.left
|
||||
anchors.bottom: textScroll.bottom
|
||||
vertical-scrollbar: textScroll
|
||||
text-wrap: true
|
||||
|
||||
VerticalScrollBar
|
||||
id: textScroll
|
||||
anchors.top: description.bottom
|
||||
anchors.bottom: okButton.top
|
||||
anchors.right: parent.right
|
||||
margin-top: 10
|
||||
margin-bottom: 10
|
||||
step: 16
|
||||
pixels-scroll: true
|
||||
|
||||
Button
|
||||
id: okButton
|
||||
!text: tr('Ok')
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: next.left
|
||||
margin-right: 10
|
||||
width: 60
|
||||
|
||||
Button
|
||||
id: cancelButton
|
||||
!text: tr('Cancel')
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
width: 60
|
Reference in New Issue
Block a user