create in game interface panels and renable about and options windows

This commit is contained in:
Eduardo Bart
2011-11-03 07:59:11 -02:00
parent b05bb7818d
commit b345a6d783
30 changed files with 400 additions and 70 deletions

View File

@@ -1,6 +1,4 @@
require 'textmessage'
require 'skill'
require 'vip'
-- private functions
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
@@ -16,28 +14,37 @@ local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
return false
end
local function createMainInterface()
-- public functions
function Game.create()
Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
Game.gameMapUi = Game.gameUi:getChildById('gameMap')
Game.gameUi.onKeyPress = onGameKeyPress
createTextInterface()
createVipWindow()
TextMessage.create()
end
local function destroyMainInterface()
function Game.destroy()
if Game.gameUi then
Game.gameUi:destroy()
Game.gameUi = nil
end
end
-- public functions
function Game.show()
Game.gameUi:show()
Game.gameUi:focus()
Game.gameMapUi:focus()
end
function Game.hide()
Game.gameUi:hide()
end
-- hooked events
function Game.onLogin()
Background.hide()
CharacterList.destroyLoadBox()
createMainInterface()
Game.show()
end
function Game.onLoginError(message)
@@ -53,7 +60,7 @@ function Game.onConnectionError(message)
end
function Game.onLogout()
Game.hide()
Background.show()
CharacterList.show()
destroyMainInterface()
end

View File

@@ -3,7 +3,6 @@ Module
description: Create the game interface, where the ingame stuff starts
author: OTClient team
website: https://github.com/edubart/otclient
version: 0.2
autoLoad: true
dependencies:
- core
@@ -14,4 +13,7 @@ Module
onLoad: |
require 'game'
require 'textmessage'
Game.create()
Game.hide()
return true

View File

@@ -1,40 +0,0 @@
skillWindow = nil
local skills = {"Fist Fighting", "Club Fighting", "Sword Fighting", "Axe Fighting", "Distance Fighting", "Shielding", "Fishing"}
function csw()
skillWindow = loadUI("/game/ui/skillwindow.otui", UI.root)
local skillPanel = skillWindow:getChildById('skillPanel')
-- create first widget cause of layout
local widget = UIWidget.create()
skillPanel:addChild(widget)
widget:setStyle('SkillFirstWidget')
-- create skills
for i=1,#skills,1 do
local nameLabel = UILabel.create()
skillPanel:addChild(nameLabel)
nameLabel:setStyle('SkillNameLabel')
nameLabel:setText(skills[i])
local levelLabel = UILabel.create()
skillPanel:addChild(levelLabel)
levelLabel:setStyle('SkillLevelLabel')
levelLabel:setId('skillLevelId' .. i)
levelLabel:setText('10')
local percentPanel = UIWidget.create()
skillPanel:addChild(percentPanel)
percentPanel:setStyle('SkillPercentPanel')
end
end
function Game.setSkill(id, level, percent)
local skillPanel = skillWindow:getChildById('skillPanel')
local levelLabel = skillPanel:getChildById('skillLevel' .. id)
end

View File

@@ -1,37 +1,41 @@
importStyles('/game/ui/textmessage.otui')
TextMessage = {}
-- require styles
importStyles '/game/ui/textmessage.otui'
-- private variables
local bottomLabelWidget, centerLabelWidget
local messageTypes = {
first = 12,
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false },
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false }
first = 12,
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
{ type = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false },
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false }
}
function createTextInterface()
-- public functions
function TextMessage.create()
bottomLabelWidget = UILabel.create()
Game.gameMapUi:addChild(bottomLabelWidget)
centerLabelWidget = UILabel.create()
Game.gameMapUi:addChild(centerLabelWidget)
end
-- hooked events
function Game.onTextMessage(type, message)
local messageType = messageTypes[type - messageTypes.first]
if messageType.showOnConsole then
-- TODO
end
if messageType.showOnWindow then
local label
if messageType.windowLocation == 'BottomLabel' then
@@ -39,18 +43,16 @@ function Game.onTextMessage(type, message)
elseif messageType.windowLocation == 'CenterLabel' then
label = centerLabelWidget
end
label:setVisible(true)
label:setForegroundColor(messageType.color)
label:setText(message)
label:setStyle(messageType.windowLocation)
time = #message * 75
scheduleEvent(function()
label:setVisible(false)
end, time)
end
end

View File

@@ -2,9 +2,24 @@ UIWidget
id: gameRootInterface
anchors.fill: parent
anchors.top: topMenu.bottom
margin.top: 1
UIMap
InterfacePanel
id: rightPanel
width: 200
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
InterfacePanel
id: bottomPanel
height: 140
anchors.left: parent.left
anchors.right: rightPanel.left
anchors.bottom: parent.bottom
MapPanel
id: gameMap
anchors.fill:parent
margin.right: 200
anchors.left: parent.left
anchors.right: rightPanel.left
anchors.top: parent.top
anchors.bottom: bottomPanel.top

View File

@@ -1,47 +0,0 @@
SkillFirstWidget < UIWidget
margin.top: 2
anchors.top: parent.top
SkillNameLabel < Label
font: verdana-11px-monochrome
margin.top: 2
margin.left: 10
margin.right: 10
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
SkillLevelLabel < Label
font: verdana-11px-monochrome
align: right
margin.top: 2
margin.left: 10
margin.right: 10
anchors.top: prev.top
anchors.left: parent.left
anchors.right: parent.right
SkillPercentPanel < UIWidget
color: blue
background-color: red
height: 4
margin.top: 2
margin.left: 10
margin.right: 10
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
Window
id: skillWindow
title: Skills
size: 200 200
Panel
id: skillPanel
anchors.fill: parent
margin.top: 19
margin.bottom: 3
margin.left: 3
margin.right: 3

View File

@@ -1,16 +0,0 @@
VipListLabel < Label
font: verdana-11px-monochrome
margin.left: 30
Window
id: vipWindow
title: VIP
size: 200 200
TextList
id: vipList
anchors.fill: parent
margin.top: 19
margin.bottom: 3
margin.left: 3
margin.right: 3

View File

@@ -1,36 +0,0 @@
vipWindow = nil
function createVipWindow()
vipWindow = loadUI("/game/ui/vipwindow.otui", Game.gameUi)
end
function Game.onAddVip(id, name, online)
local vipList = vipWindow:getChildById('vipList')
local label = UILabel.create()
vipList:addChild(label)
label:setId('vip' .. id)
label:setText(name)
label:setStyle('VipListLabel')
if online then
label:setForegroundColor('#00ff00')
else
label:setForegroundColor('#ff0000')
end
label.vipOnline = online
end
function Game.onVipStateChange(id, online)
local vipList = vipWindow:getChildById('vipList')
local label = vipList:getChildById('vip' .. id)
if online then
label:setForegroundColor('#00ff00')
else
label:setForegroundColor('#ff0000')
end
label.vipOnline = online
end