mirror of
https://github.com/OTCv8/otclientv8.git
synced 2025-10-19 22:23:28 +02:00
Version 0.999 BETA - a lot of bug fixes, improvments and more advanced bot
This commit is contained in:
56
modules/game_textedit/textedit.lua
Normal file
56
modules/game_textedit/textedit.lua
Normal file
@@ -0,0 +1,56 @@
|
||||
local activeWindow
|
||||
|
||||
function init()
|
||||
g_ui.importStyle('textedit')
|
||||
|
||||
connect(g_game, { onGameEnd = destroyWindow })
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onGameEnd = destroyWindow })
|
||||
|
||||
destroyWindow()
|
||||
end
|
||||
|
||||
function destroyWindow()
|
||||
if activeWindow then
|
||||
activeWindow:destroy()
|
||||
activeWindow = nil
|
||||
end
|
||||
end
|
||||
|
||||
function show(widget)
|
||||
if not widget then
|
||||
return
|
||||
end
|
||||
if activeWindow then
|
||||
destroyWindow()
|
||||
end
|
||||
local window = g_ui.createWidget('TextEditWindow', rootWidget)
|
||||
|
||||
local destroy = function()
|
||||
window:destroy()
|
||||
if window == activeWindow then
|
||||
activeWindow = nil
|
||||
end
|
||||
end
|
||||
local doneFunc = function()
|
||||
widget:setText(window.text:getText())
|
||||
destroy()
|
||||
end
|
||||
|
||||
window.okButton.onClick = doneFunc
|
||||
window.cancelButton.onClick = destroy
|
||||
window.onEnter = doneFunc
|
||||
window.onEscape = destroy
|
||||
|
||||
window.text:setText(widget:getText())
|
||||
|
||||
activeWindow = window
|
||||
activeWindow:raise()
|
||||
activeWindow:focus()
|
||||
end
|
||||
|
||||
function hide()
|
||||
destroyWindow()
|
||||
end
|
10
modules/game_textedit/textedit.otmod
Normal file
10
modules/game_textedit/textedit.otmod
Normal file
@@ -0,0 +1,10 @@
|
||||
Module
|
||||
name: game_textedit
|
||||
description: Allow to edit text
|
||||
author: OTClientV8
|
||||
website: https://github.com/OTCv8/otclientv8
|
||||
sandboxed: true
|
||||
dependencies: [ game_interface ]
|
||||
scripts: [ textedit ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
25
modules/game_textedit/textedit.otui
Normal file
25
modules/game_textedit/textedit.otui
Normal file
@@ -0,0 +1,25 @@
|
||||
TextEditWindow < MainWindow
|
||||
id: textedit
|
||||
size: 260 105
|
||||
!text: tr("Edit text")
|
||||
|
||||
TextEdit
|
||||
id: text
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
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