mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-10-14 06:34:55 +02:00
Resolve "Merge the best from 7.40 branch"
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
MissionLabel < Label
|
||||
font: verdana-11px-monochrome
|
||||
background-color: alpha
|
||||
text-offset: 2 0
|
||||
focusable: true
|
||||
|
||||
$focus:
|
||||
background-color: #ffffff22
|
||||
color: #ffffff
|
||||
|
||||
QuestLineWindow < MainWindow
|
||||
id: questLineWindow
|
||||
!text: tr('Quest Log')
|
||||
size: 500 400
|
||||
@onEscape: self:destroy()
|
||||
|
||||
TextList
|
||||
id: missionList
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: missionListScrollBar.left
|
||||
height: 100
|
||||
padding: 1
|
||||
focusable: false
|
||||
vertical-scrollbar: missionListScrollBar
|
||||
|
||||
VerticalScrollBar
|
||||
id: missionListScrollBar
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
height: 100
|
||||
step: 14
|
||||
pixels-scroll: true
|
||||
|
||||
FlatLabel
|
||||
id: missionDescription
|
||||
anchors.top: missionList.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: missionListScrollBar.right
|
||||
anchors.bottom: closeButton.top
|
||||
margin-bottom: 10
|
||||
margin-top: 10
|
||||
text-wrap: true
|
||||
|
||||
Button
|
||||
id: closeButton
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
!text: tr('Close')
|
||||
width: 90
|
||||
@onClick: self:getParent():destroy()
|
92
SabrehavenOTClient/modules/game_questlog/questlog.lua
Normal file
92
SabrehavenOTClient/modules/game_questlog/questlog.lua
Normal file
@@ -0,0 +1,92 @@
|
||||
questLogButton = nil
|
||||
questLineWindow = nil
|
||||
|
||||
function init()
|
||||
g_ui.importStyle('questlogwindow')
|
||||
g_ui.importStyle('questlinewindow')
|
||||
|
||||
if not g_app.isMobile() then
|
||||
questLogButton = modules.client_topmenu.addLeftGameButton('questLogButton', tr('Quest Log'), '/images/topbuttons/questlog', function() g_game.requestQuestLog() end, false, 8)
|
||||
end
|
||||
|
||||
connect(g_game, { onQuestLog = onGameQuestLog,
|
||||
onQuestLine = onGameQuestLine,
|
||||
onGameEnd = destroyWindows})
|
||||
end
|
||||
|
||||
function terminate()
|
||||
disconnect(g_game, { onQuestLog = onGameQuestLog,
|
||||
onQuestLine = onGameQuestLine,
|
||||
onGameEnd = destroyWindows})
|
||||
|
||||
destroyWindows()
|
||||
if questLogButton then
|
||||
questLogButton:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function destroyWindows()
|
||||
if questLogWindow then
|
||||
questLogWindow:destroy()
|
||||
end
|
||||
|
||||
if questLineWindow then
|
||||
questLineWindow:destroy()
|
||||
end
|
||||
end
|
||||
|
||||
function onGameQuestLog(quests)
|
||||
destroyWindows()
|
||||
|
||||
questLogWindow = g_ui.createWidget('QuestLogWindow', rootWidget)
|
||||
local questList = questLogWindow:getChildById('questList')
|
||||
|
||||
for i,questEntry in pairs(quests) do
|
||||
local id, name, completed = unpack(questEntry)
|
||||
|
||||
local questLabel = g_ui.createWidget('QuestLabel', questList)
|
||||
questLabel:setOn(completed)
|
||||
questLabel:setText(name)
|
||||
questLabel.onDoubleClick = function()
|
||||
questLogWindow:hide()
|
||||
g_game.requestQuestLine(id)
|
||||
end
|
||||
end
|
||||
|
||||
questLogWindow.onDestroy = function()
|
||||
questLogWindow = nil
|
||||
end
|
||||
|
||||
questList:focusChild(questList:getFirstChild())
|
||||
end
|
||||
|
||||
function onGameQuestLine(questId, questMissions)
|
||||
if questLogWindow then questLogWindow:hide() end
|
||||
if questLineWindow then questLineWindow:destroy() end
|
||||
|
||||
questLineWindow = g_ui.createWidget('QuestLineWindow', rootWidget)
|
||||
local missionList = questLineWindow:getChildById('missionList')
|
||||
local missionDescription = questLineWindow:getChildById('missionDescription')
|
||||
|
||||
connect(missionList, { onChildFocusChange = function(self, focusedChild)
|
||||
if focusedChild == nil then return end
|
||||
missionDescription:setText(focusedChild.description)
|
||||
end })
|
||||
|
||||
for i,questMission in pairs(questMissions) do
|
||||
local name, description = unpack(questMission)
|
||||
|
||||
local missionLabel = g_ui.createWidget('MissionLabel')
|
||||
missionLabel:setText(name)
|
||||
missionLabel.description = description
|
||||
missionList:addChild(missionLabel)
|
||||
end
|
||||
|
||||
questLineWindow.onDestroy = function()
|
||||
if questLogWindow then questLogWindow:show() end
|
||||
questLineWindow = nil
|
||||
end
|
||||
|
||||
missionList:focusChild(missionList:getFirstChild())
|
||||
end
|
||||
|
9
SabrehavenOTClient/modules/game_questlog/questlog.otmod
Normal file
9
SabrehavenOTClient/modules/game_questlog/questlog.otmod
Normal file
@@ -0,0 +1,9 @@
|
||||
Module
|
||||
name: game_questlog
|
||||
description: View game quests status
|
||||
author: edubart
|
||||
website: https://github.com/edubart/otclient
|
||||
sandboxed: true
|
||||
scripts: [ questlog ]
|
||||
@onLoad: init()
|
||||
@onUnload: terminate()
|
54
SabrehavenOTClient/modules/game_questlog/questlogwindow.otui
Normal file
54
SabrehavenOTClient/modules/game_questlog/questlogwindow.otui
Normal file
@@ -0,0 +1,54 @@
|
||||
QuestLabel < Label
|
||||
font: verdana-11px-monochrome
|
||||
text-offset: 2 0
|
||||
focusable: true
|
||||
color: #aaaaaa
|
||||
background-color: alpha
|
||||
|
||||
$on:
|
||||
color: #00aa00
|
||||
$!on:
|
||||
color: #aaaaaa
|
||||
|
||||
$focus:
|
||||
background-color: #444444
|
||||
|
||||
$on focus:
|
||||
color: #00ff00
|
||||
$!on focus:
|
||||
color: #ffffff
|
||||
|
||||
QuestLogWindow < MainWindow
|
||||
id: questLogWindow
|
||||
!text: tr('Quest Log')
|
||||
size: 500 400
|
||||
@onEscape: self:destroy()
|
||||
$mobile:
|
||||
size: 500 350
|
||||
|
||||
TextList
|
||||
id: questList
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: closeButton.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: questListScrollBar.left
|
||||
margin-bottom: 10
|
||||
focusable: false
|
||||
vertical-scrollbar: questListScrollBar
|
||||
|
||||
VerticalScrollBar
|
||||
id: questListScrollBar
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: closeButton.top
|
||||
anchors.right: parent.right
|
||||
margin-bottom: 10
|
||||
step: 14
|
||||
pixels-scroll: true
|
||||
|
||||
Button
|
||||
id: closeButton
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
!text: tr('Close')
|
||||
width: 90
|
||||
@onClick: self:getParent():destroy()
|
Reference in New Issue
Block a user