Skip to content

Commit

Permalink
feat: character list window
Browse files Browse the repository at this point in the history
  • Loading branch information
majestyotbr committed Oct 20, 2023
1 parent 01eeb84 commit d90c999
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 12 deletions.
Binary file added data/images/game/entergame/dailyreward_collected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/game/entergame/hidden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/game/entergame/maincharacter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/game/entergame/nopremium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/game/entergame/premium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 45 additions & 1 deletion modules/client_entergame/characterlist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local waitingWindow
local updateWaitEvent
local resendWaitEvent
local loginEvent
local outfitCreatureBox

-- private functions
local function tryLogin(charInfo, tries)
Expand Down Expand Up @@ -94,7 +95,18 @@ local function resendWait()
worldHost = selected.worldHost,
worldPort = selected.worldPort,
worldName = selected.worldName,
characterName = selected.characterName
characterName = selected.characterName,
characterLevel = selected.characterLevel,
main = selected.main,
dailyreward = selected.dailyreward,
hidden = selected.hidden,
outfitid = selected.outfitid,
headcolor = selected.headcolor,
torsocolor = selected.torsocolor,
legscolor = selected.legscolor,
detailcolor = selected.detailcolor,
addonsflags = selected.addonsflags,
characterVocation = selected.characterVocation
}
tryLogin(charInfo)
end
Expand Down Expand Up @@ -255,6 +267,7 @@ function CharacterList.create(characters, account, otui)

characterList:destroyChildren()
local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel')
local accountStatusIcon = charactersWindow:getChildById('accountStatusIcon')

local focusLabel
for i, characterInfo in ipairs(characters) do
Expand All @@ -276,6 +289,35 @@ function CharacterList.create(characters, account, otui)
end
end

local creatureDisplay = widget:getChildById('outfitCreatureBox', characterList)
creatureDisplay:setSize("64 64")
local creature = Creature.create()
local outfit = {type = characterInfo.outfitid, head = characterInfo.headcolor, body = characterInfo.torsocolor, legs = characterInfo.legscolor, feet = characterInfo.detailcolor, addons = characterInfo.addonsflags}
creature:setOutfit(outfit)
creature:setDirection(2)
creatureDisplay:setCreature(creature)

local mainCharacter = widget:getChildById('mainCharacter', characterList)
if characterInfo.main then
mainCharacter:setImageSource('/images/game/entergame/maincharacter')
else
mainCharacter:setImageSource('')
end

local statusDailyReward = widget:getChildById('statusDailyReward', characterList)
if characterInfo.dailyreward == 0 then
statusDailyReward:setImageSource('/images/game/entergame/dailyreward_collected')
else
statusDailyReward:setImageSource('/images/game/entergame/dailyreward_notcollected')
end

local statusHidden = widget:getChildById('statusHidden', characterList)
if characterInfo.hidden then
statusHidden:setImageSource('/images/game/entergame/hidden')
else
statusHidden:setImageSource('')
end

-- these are used by login
widget.characterName = characterInfo.name
widget.worldName = characterInfo.worldName
Expand Down Expand Up @@ -313,12 +355,14 @@ function CharacterList.create(characters, account, otui)

if account.subStatus == SubscriptionStatus.Free then
accountStatusLabel:setText(('%s%s'):format(tr('Free Account'), status))
accountStatusIcon:setImageSource('/images/game/entergame/nopremium')
elseif account.subStatus == SubscriptionStatus.Premium then
if account.premDays == 0 or account.premDays == 65535 then
accountStatusLabel:setText(('%s%s'):format(tr('Gratis Premium Account'), status))
else
accountStatusLabel:setText(('%s%s'):format(tr('Premium Account (%s) days left', account.premDays), status))
end
accountStatusIcon:setImageSource('/images/game/entergame/premium')
end

if account.premDays > 0 and account.premDays <= 7 then
Expand Down
157 changes: 146 additions & 11 deletions modules/client_entergame/characterlist.otui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CharacterWidget < UIWidget
height: 14
height: 64
background-color: alpha
&updateOnStates: |
function(self)
Expand All @@ -14,11 +14,80 @@ CharacterWidget < UIWidget
$focus:
background-color: #ffffff22

Creature
id: outfitCreatureBox
size: 64 64
anchors.top: parent.top
anchors.left: parent.left
padding-left: 10
padding-bottom: 5
creatureDisplay:setCreature(creature)
fixed-creature-size: true

Label
id: name
color: #bbbbbb
anchors.top: parent.top
anchors.left: parent.left
margin-left: 65
font: verdana-11px-monochrome
text-auto-resize: true
background-color: alpha
text-offset: 2 0

$on:
color: #ffffff

Label
id: mainCharacter
size: 9 8
anchors.top: parent.top
anchors.left: prev.right
margin-left: 6
margin-top: 2
image-source: /images/game/entergame/maincharacter
image-clip: 0 0 9 8

Label
id: statusDailyReward
size: 11 19
anchors.top: parent.top
anchors.left: parent.left
margin-left: 252
margin-top: 2
image-source: /images/game/entergame/dailyreward_collected
image-clip: 0 0 11 19

Label
id: statusHidden
size: 11 19
anchors.top: parent.top
anchors.left: parent.left
margin-left: 267
margin-top: 2
image-source: /images/game/entergame/hidden
image-clip: 0 0 11 19

Label
id: level
color: #bbbbbb
anchors.top: parent.top
anchors.left: parent.left
margin-left: 300
font: verdana-11px-monochrome
text-auto-resize: true
background-color: alpha
text-offset: 2 0

$on:
color: #ffffff

Label
id: vocation
color: #bbbbbb
anchors.top: parent.top
anchors.left: parent.left
margin-left: 350
font: verdana-11px-monochrome
text-auto-resize: true
background-color: alpha
Expand All @@ -31,12 +100,12 @@ CharacterWidget < UIWidget
id: worldName
color: #bbbbbb
anchors.top: parent.top
anchors.right: parent.right
margin-right: 5
anchors.left: parent.left
margin-left: 502
font: verdana-11px-monochrome
text-auto-resize: true
background-color: alpha
&baseText: '(%s)'
&baseText: '%s'

$on:
color: #ffffff
Expand All @@ -45,31 +114,64 @@ MainWindow
id: charactersWindow
!text: tr('Character List')
visible: false
draggable: false
@onEnter: CharacterList.doLogin()
@onEscape: CharacterList.hide(true)
@onSetup: |
g_keyboard.bindKeyPress('Up', function() self:getChildById('characters'):focusPreviousChild(KeyboardFocusReason) end, self)
g_keyboard.bindKeyPress('Down', function() self:getChildById('characters'):focusNextChild(KeyboardFocusReason) end, self)
if g_game.getFeature(GamePreviewState) then
self:setSize({width = 350, height = 400})
self:setSize({width = 745, height = 430})
else
self:setSize({width = 250, height = 248})
end

TextList
id: characters
background-color: #565656
background-color: #404040
anchors.top: parent.top
anchors.left: parent.left
anchors.right: characterListScrollBar.left
anchors.bottom: accountStatusCaption.top
margin-bottom: 5
padding: 1
padding-top: 20
focusable: false
vertical-scrollbar: characterListScrollBar
auto-focus: first

FlatLabel
width: 250
anchors.left: parent.left
anchors.top: characters.top
!text: tr('Character') .. ''

FlatLabel
width: 50
anchors.left: parent.left
anchors.top: characters.top
margin-left: 250
!text: tr('Status') .. ''

FlatLabel
width: 50
anchors.left: parent.left
anchors.top: characters.top
margin-left: 300
!text: tr('Level') .. ''

FlatLabel
width: 150
anchors.left: parent.left
anchors.top: characters.top
margin-left: 350
!text: tr('Vocation') .. ''

FlatLabel
width: 201
anchors.right: characters.right
anchors.top: characters.top
!text: tr('World') .. ''

VerticalScrollBar
id: characterListScrollBar
anchors.top: parent.top
Expand All @@ -79,21 +181,54 @@ MainWindow
step: 14
pixels-scroll: true

VerticalSeparator
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: prev.bottom
margin-left: 249

VerticalSeparator
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: prev.bottom
margin-left: 299

VerticalSeparator
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: prev.bottom
margin-left: 349

VerticalSeparator
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: prev.bottom
margin-left: 499

Label
id: accountStatusCaption
!text: tr('Account Status') .. ':'
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
margin-bottom: 1
margin-bottom: 5

Label
id: accountStatusIcon
size: 22 20
anchors.left: parent.left
anchors.bottom: next.bottom
image-source: /images/game/entergame/premium
image-clip: 0 0 22 20

Label
id: accountStatusLabel
!text: tr('Free Account')
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: separator.top
margin-bottom: 5
anchors.bottom: next.bottom
margin-bottom: 15
padding-bottom: 2
text-offset: 25 0
text-auto-resize: true

$on:
Expand Down
11 changes: 11 additions & 0 deletions modules/client_entergame/entergame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,17 @@ function EnterGame.tryHttpLogin(clientVersion)
local world = worlds[character.worldid]
characters[index] = {
name = character.name,
level = character.level,
main = character.ismaincharacter,
dailyreward = character.dailyrewardstate,
hidden = character.ishidden,
vocation = character.vocation,
outfitid = character.outfitid,
headcolor = character.headcolor,
torsocolor = character.torsocolor,
legscolor = character.legscolor,
detailcolor = character.detailcolor,
addonsflags = character.addonsflags,
worldName = world.name,
worldIp = world.ip,
worldPort = world.port,
Expand Down

0 comments on commit d90c999

Please sign in to comment.