From 662dfa9fb008fac66b15dfcfaa65703190f17c82 Mon Sep 17 00:00:00 2001 From: Marcos <66353315+marcosvf132@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:45:47 -0300 Subject: [PATCH] Implement old-protocol compatibility --- modules/client_entergame/characterlist.lua | 67 +++++----- modules/client_entergame/characterlist.otui | 129 +++++++++++++++++--- modules/game_features/features.lua | 1 + modules/gamelib/const.lua | 1 + src/client/const.h | 3 +- 5 files changed, 157 insertions(+), 44 deletions(-) diff --git a/modules/client_entergame/characterlist.lua b/modules/client_entergame/characterlist.lua index a7399ca243..12a87feba6 100644 --- a/modules/client_entergame/characterlist.lua +++ b/modules/client_entergame/characterlist.lua @@ -267,7 +267,10 @@ function CharacterList.create(characters, account, otui) characterList:destroyChildren() local accountStatusLabel = charactersWindow:getChildById('accountStatusLabel') - local accountStatusIcon = charactersWindow:getChildById('accountStatusIcon') + local accountStatusIcon = nil + if g_game.getFeature(GameEnterGameShowAppearance) then + accountStatusIcon = charactersWindow:getChildById('accountStatusIcon') + end local focusLabel for i, characterInfo in ipairs(characters) do @@ -289,33 +292,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 + if g_game.getFeature(GameEnterGameShowAppearance) then + 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 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('') + local statusHidden = widget:getChildById('statusHidden', characterList) + if characterInfo.hidden then + statusHidden:setImageSource('/images/game/entergame/hidden') + else + statusHidden:setImageSource('') + end end -- these are used by login @@ -355,14 +360,18 @@ 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') + if accountStatusIcon ~= nil then + accountStatusIcon:setImageSource('/images/game/entergame/nopremium') + end 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') + if accountStatusIcon ~= nil then + accountStatusIcon:setImageSource('/images/game/entergame/premium') + end end if account.premDays > 0 and account.premDays <= 7 then @@ -458,4 +467,4 @@ function CharacterList.cancelWait() CharacterList.destroyLoadBox() CharacterList.showAgain() -end +end \ No newline at end of file diff --git a/modules/client_entergame/characterlist.otui b/modules/client_entergame/characterlist.otui index 9b002e4a8d..8b76c68272 100644 --- a/modules/client_entergame/characterlist.otui +++ b/modules/client_entergame/characterlist.otui @@ -1,5 +1,5 @@ CharacterWidget < UIWidget - height: 64 + height: 14 background-color: alpha &updateOnStates: | function(self) @@ -9,7 +9,11 @@ CharacterWidget < UIWidget end end @onFocusChange: self:updateOnStates() - @onSetup: self:updateOnStates() + @onSetup: | + self:updateOnStates() + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setHeight(64) + end $focus: background-color: #ffffff22 @@ -23,17 +27,24 @@ CharacterWidget < UIWidget padding-bottom: 5 creatureDisplay:setCreature(creature) fixed-creature-size: true + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end 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 + @onSetup: | + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setMarginLeft(65) + end $on: color: #ffffff @@ -47,6 +58,10 @@ CharacterWidget < UIWidget margin-top: 2 image-source: /images/game/entergame/maincharacter image-clip: 0 0 9 8 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end Label id: statusDailyReward @@ -57,6 +72,10 @@ CharacterWidget < UIWidget margin-top: 2 image-source: /images/game/entergame/dailyreward_collected image-clip: 0 0 11 19 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end Label id: statusHidden @@ -67,6 +86,10 @@ CharacterWidget < UIWidget margin-top: 2 image-source: /images/game/entergame/hidden image-clip: 0 0 11 19 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end Label id: level @@ -78,6 +101,10 @@ CharacterWidget < UIWidget text-auto-resize: true background-color: alpha text-offset: 2 0 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end $on: color: #ffffff @@ -92,6 +119,10 @@ CharacterWidget < UIWidget text-auto-resize: true background-color: alpha text-offset: 2 0 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end $on: color: #ffffff @@ -100,12 +131,19 @@ CharacterWidget < UIWidget id: worldName color: #bbbbbb anchors.top: parent.top - anchors.left: parent.left - margin-left: 502 font: verdana-11px-monochrome text-auto-resize: true background-color: alpha - &baseText: '%s' + &baseText: '(%s)' + @onSetup: | + if g_game.getFeature(GameEnterGameShowAppearance) then + self:addAnchor(AnchorLeft, 'parent', AnchorLeft) + self:setMarginLeft(502) + self.baseText = '%s' + else + self:addAnchor(AnchorRight, 'parent', AnchorRight) + self:setMarginRight(5) + end $on: color: #ffffff @@ -120,7 +158,11 @@ MainWindow 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 = 745, height = 430}) + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setSize({width = 745, height = 430}) + else + self:setSize({width = 350, height = 400}) + end else self:setSize({width = 250, height = 248}) end @@ -134,16 +176,27 @@ MainWindow anchors.bottom: accountStatusCaption.top margin-bottom: 5 padding: 1 - padding-top: 20 focusable: false vertical-scrollbar: characterListScrollBar auto-focus: first + @onSetup: | + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setBackgroundColor("#404040") + self:setPaddingTop(20) + else + self:setBackgroundColor("#565656") + end + FlatLabel width: 250 anchors.left: parent.left anchors.top: characters.top !text: tr('Character') .. '' + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end FlatLabel width: 50 @@ -151,6 +204,10 @@ MainWindow anchors.top: characters.top margin-left: 250 !text: tr('Status') .. '' + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end FlatLabel width: 50 @@ -158,6 +215,10 @@ MainWindow anchors.top: characters.top margin-left: 300 !text: tr('Level') .. '' + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end FlatLabel width: 150 @@ -165,12 +226,20 @@ MainWindow anchors.top: characters.top margin-left: 350 !text: tr('Vocation') .. '' + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end FlatLabel width: 201 anchors.right: characters.right anchors.top: characters.top !text: tr('World') .. '' + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end VerticalScrollBar id: characterListScrollBar @@ -186,24 +255,40 @@ MainWindow anchors.top: parent.top anchors.bottom: prev.bottom margin-left: 249 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end VerticalSeparator anchors.left: parent.left anchors.top: parent.top anchors.bottom: prev.bottom margin-left: 299 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end VerticalSeparator anchors.left: parent.left anchors.top: parent.top anchors.bottom: prev.bottom margin-left: 349 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end VerticalSeparator anchors.left: parent.left anchors.top: parent.top anchors.bottom: prev.bottom margin-left: 499 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end Label id: accountStatusCaption @@ -211,7 +296,12 @@ MainWindow anchors.left: parent.left anchors.right: parent.right anchors.bottom: next.top - margin-bottom: 5 + @onSetup: | + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setMarginBottom(5) + else + self:setMarginBottom(1) + end Label id: accountStatusIcon @@ -220,16 +310,27 @@ MainWindow anchors.bottom: next.bottom image-source: /images/game/entergame/premium image-clip: 0 0 22 20 + @onSetup: | + if not(g_game.getFeature(GameEnterGameShowAppearance)) then + self:hide() + end Label id: accountStatusLabel !text: tr('Free Account') anchors.left: parent.left - anchors.bottom: next.bottom - margin-bottom: 15 - padding-bottom: 2 - text-offset: 25 0 text-auto-resize: true + @onSetup: | + if g_game.getFeature(GameEnterGameShowAppearance) then + self:setMarginBottom(15) + self:setPaddingBottom(2) + self:setTextOffset({x = 25, y = 0}) + self:addAnchor(AnchorBottom, 'next', AnchorBottom) + else + self:setMarginBottom(5) + self:addAnchor(AnchorRight, 'parent', AnchorRight) + self:addAnchor(AnchorBottom, 'separator', AnchorTop) + end $on: color: #FF0000 @@ -267,4 +368,4 @@ MainWindow width: 64 anchors.right: parent.right anchors.bottom: parent.bottom - @onClick: CharacterList.hide(true) + @onClick: CharacterList.hide(true) \ No newline at end of file diff --git a/modules/game_features/features.lua b/modules/game_features/features.lua index 10477fdf3e..49fce13987 100644 --- a/modules/game_features/features.lua +++ b/modules/game_features/features.lua @@ -179,6 +179,7 @@ controller:registerEvents(g_game, { g_game.enableFeature(GameThingQuickLoot); g_game.enableFeature(GameTournamentPackets); g_game.enableFeature(GameVipGroups); + g_game.enableFeature(GameEnterGameShowAppearance); end if version >= 1260 then diff --git a/modules/gamelib/const.lua b/modules/gamelib/const.lua index 7b814f2e19..72ed136bbc 100644 --- a/modules/gamelib/const.lua +++ b/modules/gamelib/const.lua @@ -190,6 +190,7 @@ GameItemAugment = 110 GameDynamicBugReporter = 111 GameWrapKit = 112 GameContainerFilter = 113 +GameEnterGameShowAppearance = 114 TextColors = { red = '#f55e5e', -- '#c83200' diff --git a/src/client/const.h b/src/client/const.h index ce41951a53..98b9787588 100644 --- a/src/client/const.h +++ b/src/client/const.h @@ -541,7 +541,8 @@ namespace Otc GameDynamicBugReporter = 111, GameWrapKit = 112, GameContainerFilter = 113, - LastGameFeature = 114 + GameEnterGameShowAppearance = 114, + LastGameFeature = 115 }; enum MagicEffectsType_t : uint8_t