mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 04:53:27 +02:00
Use new coding style in game modules
Lots of refactoring and changes Remove docs folder
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
RuleViolation = {}
|
||||
|
||||
-- private variables
|
||||
local rvreasons = {}
|
||||
rvreasons = {}
|
||||
rvreasons[1] = tr("1a) Offensive Name")
|
||||
rvreasons[2] = tr("1b) Invalid Name Format")
|
||||
rvreasons[3] = tr("1c) Unsuitable Name")
|
||||
@@ -24,7 +21,7 @@ rvreasons[19] = tr("4c) False Report to Gamemaster")
|
||||
rvreasons[20] = tr("Destructive Behaviour")
|
||||
rvreasons[21] = tr("Excessive Unjustified Player Killing")
|
||||
|
||||
local rvactions = {}
|
||||
rvactions = {}
|
||||
rvactions[0] = tr("Notation")
|
||||
rvactions[1] = tr("Name Report")
|
||||
rvactions[2] = tr("Banishment")
|
||||
@@ -33,16 +30,38 @@ rvactions[4] = tr("Banishment + Final Warning")
|
||||
rvactions[5] = tr("Name Report + Banishment + Final Warning")
|
||||
rvactions[6] = tr("Statement Report")
|
||||
|
||||
local ruleViolationWindow
|
||||
local reasonsTextList
|
||||
local actionsTextList
|
||||
ruleViolationWindow = nil
|
||||
reasonsTextList = nil
|
||||
actionsTextList = nil
|
||||
|
||||
-- public functions
|
||||
function RuleViolation.hasWindowAccess()
|
||||
function init()
|
||||
connect(g_game, { onGMActions = loadReasons })
|
||||
|
||||
ruleViolationWindow = g_ui.displayUI('ruleviolation.otui')
|
||||
ruleViolationWindow:setVisible(false)
|
||||
|
||||
reasonsTextList = ruleViolationWindow:getChildById('reasonList')
|
||||
actionsTextList = ruleViolationWindow:getChildById('actionList')
|
||||
|
||||
g_keyboard.bindKeyDown('Ctrl+Y', show)
|
||||
|
||||
if g_game.isOnline() then
|
||||
loadReasons()
|
||||
end
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onGMActions = loadReasons })
|
||||
g_keyboard.unbindKeyDown('Ctrl+Y')
|
||||
|
||||
ruleViolationWindow:destroy()
|
||||
end
|
||||
|
||||
function hasWindowAccess()
|
||||
return reasonsTextList:getChildCount() > 0
|
||||
end
|
||||
|
||||
function RuleViolation.loadReasons()
|
||||
function loadReasons()
|
||||
reasonsTextList:destroyChildren()
|
||||
|
||||
local actions = g_game.getGMActions()
|
||||
@@ -53,37 +72,11 @@ function RuleViolation.loadReasons()
|
||||
label.actionFlags = actionFlags
|
||||
end
|
||||
|
||||
if not RuleViolation.hasWindowAccess() and ruleViolationWindow:isVisible() then RuleViolation.hide() end
|
||||
if not hasWindowAccess() and ruleViolationWindow:isVisible() then hide() end
|
||||
end
|
||||
|
||||
function RuleViolation.init()
|
||||
connect(g_game, { onGMActions = RuleViolation.loadReasons })
|
||||
|
||||
ruleViolationWindow = g_ui.displayUI('ruleviolation.otui')
|
||||
ruleViolationWindow:setVisible(false)
|
||||
|
||||
reasonsTextList = ruleViolationWindow:getChildById('reasonList')
|
||||
actionsTextList = ruleViolationWindow:getChildById('actionList')
|
||||
|
||||
g_keyboard.bindKeyDown('Ctrl+Y', RuleViolation.show)
|
||||
|
||||
if g_game.isOnline() then
|
||||
RuleViolation.loadReasons()
|
||||
end
|
||||
end
|
||||
|
||||
function RuleViolation.terminate()
|
||||
disconnect(g_game, { onGMActions = RuleViolation.loadReasons })
|
||||
|
||||
ruleViolationWindow:destroy()
|
||||
ruleViolationWindow = nil
|
||||
|
||||
reasonsTextList = nil
|
||||
actionsTextList = nil
|
||||
end
|
||||
|
||||
function RuleViolation.show(target, statement)
|
||||
if g_game.isOnline() and RuleViolation.hasWindowAccess() then
|
||||
function show(target, statement)
|
||||
if g_game.isOnline() and hasWindowAccess() then
|
||||
if target then
|
||||
ruleViolationWindow:getChildById('nameText'):setText(target)
|
||||
end
|
||||
@@ -97,12 +90,12 @@ function RuleViolation.show(target, statement)
|
||||
end
|
||||
end
|
||||
|
||||
function RuleViolation.hide()
|
||||
function hide()
|
||||
ruleViolationWindow:hide()
|
||||
RuleViolation.clearForm()
|
||||
clearForm()
|
||||
end
|
||||
|
||||
function RuleViolation.onSelectReason(reasonLabel, focused)
|
||||
function onSelectReason(reasonLabel, focused)
|
||||
if reasonLabel.actionFlags and focused then
|
||||
actionsTextList:destroyChildren()
|
||||
for actionBaseFlag = 0, #rvactions do
|
||||
@@ -116,7 +109,7 @@ function RuleViolation.onSelectReason(reasonLabel, focused)
|
||||
end
|
||||
end
|
||||
|
||||
function RuleViolation.report()
|
||||
function report()
|
||||
local target = ruleViolationWindow:getChildById('nameText'):getText()
|
||||
local reason = reasonsTextList:getFocusedChild().reasonId
|
||||
local action = actionsTextList:getFocusedChild().actionId
|
||||
@@ -130,13 +123,13 @@ function RuleViolation.report()
|
||||
displayErrorBox(tr("Error"), tr("You must enter a comment."))
|
||||
else
|
||||
g_game.reportRuleVilation(target, reason, action, comment, statement, statementId, ipBanishment)
|
||||
RuleViolation.hide()
|
||||
hide()
|
||||
end
|
||||
end
|
||||
|
||||
function RuleViolation.clearForm()
|
||||
function clearForm()
|
||||
ruleViolationWindow:getChildById('nameText'):clearText()
|
||||
ruleViolationWindow:getChildById('commentText'):clearText()
|
||||
ruleViolationWindow:getChildById('statementText'):clearText()
|
||||
ruleViolationWindow:getChildById('ipBanCheckBox'):setChecked(false)
|
||||
end
|
||||
end
|
||||
|
@@ -3,13 +3,7 @@ Module
|
||||
description: Rule violation interface (Ctrl+Y)
|
||||
author: andrefaramir
|
||||
website: www.otclient.info
|
||||
|
||||
dependencies:
|
||||
- game_interface
|
||||
|
||||
@onLoad: |
|
||||
dofile 'ruleviolation'
|
||||
RuleViolation.init()
|
||||
|
||||
@onUnload: |
|
||||
RuleViolation.terminate()
|
||||
sandboxed: true
|
||||
scripts: [ ruleviolation.lua ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
||||
|
@@ -3,7 +3,7 @@ RVListLabel < Label
|
||||
text-offset: 2 0
|
||||
focusable: true
|
||||
@onFocusChange: function (self, focused) RuleViolation.onSelectReason(self, focused) end
|
||||
|
||||
|
||||
$focus:
|
||||
background-color: #ffffff22
|
||||
color: #ffffff
|
||||
@@ -11,10 +11,10 @@ RVListLabel < Label
|
||||
RVLabel < Label
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
|
||||
|
||||
$!first:
|
||||
margin-top: 10
|
||||
anchors.top: prev.bottom
|
||||
@@ -23,34 +23,34 @@ RVTextEdit < TextEdit
|
||||
margin-top: 2
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
|
||||
$first:
|
||||
anchors.top: parent.top
|
||||
|
||||
|
||||
$!first:
|
||||
anchors.top: prev.bottom
|
||||
|
||||
|
||||
MainWindow
|
||||
id: ruleViolationWindow
|
||||
size: 400 445
|
||||
text: Rule Violation
|
||||
|
||||
text: Rule Violation
|
||||
|
||||
RVLabel
|
||||
!text: tr('Name:')
|
||||
|
||||
|
||||
RVTextEdit
|
||||
id: nameText
|
||||
|
||||
|
||||
RVLabel
|
||||
!text: tr('Statement:')
|
||||
|
||||
|
||||
RVTextEdit
|
||||
id: statementText
|
||||
enabled: false
|
||||
|
||||
|
||||
RVLabel
|
||||
!text: tr('Reason:')
|
||||
|
||||
|
||||
TextList
|
||||
id: reasonList
|
||||
height: 100
|
||||
@@ -67,11 +67,11 @@ MainWindow
|
||||
anchors.bottom: reasonList.bottom
|
||||
anchors.right: reasonList.right
|
||||
step: 14
|
||||
pixels-scroll: true
|
||||
|
||||
pixels-scroll: true
|
||||
|
||||
RVLabel
|
||||
!text: tr('Action:')
|
||||
|
||||
|
||||
TextList
|
||||
id: actionList
|
||||
height: 60
|
||||
@@ -88,8 +88,8 @@ MainWindow
|
||||
anchors.bottom: actionList.bottom
|
||||
anchors.right: actionList.right
|
||||
step: 14
|
||||
pixels-scroll: true
|
||||
|
||||
pixels-scroll: true
|
||||
|
||||
CheckBox
|
||||
id: ipBanCheckBox
|
||||
!text: tr('IP Address Banishment')
|
||||
@@ -97,24 +97,24 @@ MainWindow
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
|
||||
RVLabel
|
||||
!text: tr('Comment:')
|
||||
|
||||
|
||||
RVTextEdit
|
||||
id: commentText
|
||||
|
||||
|
||||
Button
|
||||
!text: tr('Cancel')
|
||||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: RuleViolation.hide()
|
||||
|
||||
|
||||
Button
|
||||
!text: tr('Ok')
|
||||
width: 64
|
||||
margin-right: 5
|
||||
anchors.right: prev.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: RuleViolation.report()
|
Reference in New Issue
Block a user