Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Blessings #825

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions modules/game_blessing/blessing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<style>
.blessing-window {
width: 615;
height: 460;
padding-top: 36;
padding-left: 16;
padding-right: 16;
padding-bottom: 16;
font: verdana-11px-antialised;
opacity: 1;
}

.promotion-status {
width: 583;
height: 85;
margin-top: 10;
display: block;
}

.death-penalty {
width: 583;
height: 113;
margin-top: 10;
display: block;
}

.premium-image {
margin-top: -10;
float: right;
}

.test {
display: block;
margin-top: 22;
width: 580;
}

.contenedor {
width: 580;
display: block;
font: verdana-11px-antialised;
}

.record-blessing {
width: 580;
height: 120;
display: block;
}
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved

.mini-panel {
width: 580;
height: 300;
background-color: #404040;

margin-bottom: 10;
display: block;
}


</style>

<window id="main" class="blessing-window" text="Blessings">

<minipanel class="mini-panel" text="History" id="blessingHistory" >
<UIScrollArea id ="here" layout="type: verticalBox" style="height: 222;width: 570;margin-top:-12;background-color: #404040" >
<!--
<UIScrollArea id ="here" layout="type: verticalBox" style="height: 222;width: 570;margin-top:-12; vertical-scrollbar: ListBadgeScrollbar" >
<VerticalScrollBar id ="scroll" >
</VerticalScrollBar> -->

</UIScrollArea>
</minipanel>

<minipanel anchor="parent" class="record-blessing" text="Record of Blessings" id="test"
layout="type: horizontalBox; fit-children: true;cell-size: 88 20;cell-spacing: 1">
</minipanel>

<minipanel class="promotion-status" text="Promotion and Premium Status" id="promotionStatus2">
<label id="rank" style="margin-top:12">If your account had Premium status, your XP loss would be 0% lower.</label>
<BlessingButton class="premium-image" id="premium_only"></BlessingButton>
</minipanel>

<minipanel class="death-penalty" text="Effect on Death Penalty" id="promotionStatus">
<label class="contenedor" id="fightRules">- Depending on the fair fight rules, you will lose between 2% and 1% less
XP and skill </br> \n points upon your next PvP death.</label>
<label class="contenedor" id="expLoss">- You will lose 3% less XP and skill points upon your next PvE death.</label>
<label class="contenedor" id="containerLoss">- There is a 2% chance that you will lose your equipped container on
your next\n death.</label>
<label class="contenedor" id="equipmentLoss">- There is a 1% chance that you will lose items upon your next
death.</label>
</minipanel>

<HorizontalSeparator class="test"></HorizontalSeparator>

<button style="margin-top:12" onclick="self:showHistory()" id="historyButton">history</button>
<button style="margin-top:12" onclick="self:close()">close</button>
</window>
138 changes: 138 additions & 0 deletions modules/game_blessing/blessing.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
BlessingController = Controller:new()

function BlessingController:onInit()
end

function BlessingController:onTerminate()
-- BlessingController:findWidget("#main"):destroy()
end

function BlessingController:onGameStart()
g_ui.importStyle("style.otui")
BlessingController:loadHtml('blessing.html', g_ui.getRootWidget())

BlessingController:registerEvents(g_game, {
onUpdateBlessDialog = onUpdateBlessDialog
})
BlessingController.ui:hide()
end

function BlessingController:onGameEnd()
if BlessingController.ui:isVisible() then
BlessingController.ui:hide()
end
end

function BlessingController:close()
hide()
end

function BlessingController:showHistory()
if BlessingController.ui.blessingHistory:isVisible() then
setBlessing()
else
setHistory()
end
end

function setHistory()
local ui = BlessingController.ui
ui.test:hide()
ui.promotionStatus2:hide()
ui.promotionStatus:hide()
ui.blessingHistory:show()
ui.historyButton:setText("Back")
end

function setBlessing()
local ui = BlessingController.ui
ui.test:show()
ui.promotionStatus2:show()
ui.promotionStatus:show()
ui.blessingHistory:hide()
ui.historyButton:setText("History")
end
kokekanon marked this conversation as resolved.
Show resolved Hide resolved

function toggle()
if not BlessingController.ui then
return
end

if BlessingController.ui:isVisible() then
return hide()
end
show()
end

function hide()
if not BlessingController.ui then
return
end
BlessingController.ui:hide()
end

function show()
if not BlessingController.ui then
return
end
g_game.requestBless()
BlessingController.ui:show()
BlessingController.ui:raise()
BlessingController.ui:focus()
setBlessing()
end

function onUpdateBlessDialog(data)

kokekanon marked this conversation as resolved.
Show resolved Hide resolved
BlessingController.ui.test:destroyChildren()

for i, entry in ipairs(data.blesses) do
local label = g_ui.createWidget("blessingTEST", BlessingController.ui.test)
local totalCount = entry.playerBlessCount + entry.store
label.text:setText(entry.playerBlessCount .. " (" .. entry.store .. ")")
if totalCount >= 1 then
label.enabled:setImageSource("images/" .. i .. "_on")
end
end

if (data.promotion ~= 0) then
BlessingController.ui.promotionStatus2.premium_only:setOn(false)
BlessingController.ui.promotionStatus2.rank:setColoredText(
"Your character is promoted and your account has Premium\nstatus. As a result, your XP loss is reduced by {30%, #f75f5f}.")
else
BlessingController.ui.promotionStatus2.rank:setColoredText(
"Your character is promoted and your account has Premium\nstatus. As a result, your XP loss is reduced by {0%, #f75f5f}.")
BlessingController.ui.promotionStatus2.premium_only:setOn(true)
end

BlessingController.ui.promotionStatus.fightRules:setColoredText(
"- Depending on the fair fight rules, you will lose between {" .. data.pvpMinXpLoss .. ", #f75f5f} and {" ..
data.pvpMaxXpLoss .. "%, #f75f5f} less XP and skill points \nupon your next PvP death.")

BlessingController.ui.promotionStatus.expLoss:setColoredText(
"- You will lose {" .. data.pveExpLoss .. "%, #f75f5f}% less XP and skill points upon your next PvE death.")

BlessingController.ui.promotionStatus.containerLoss:setColoredText(
"- There is a {" .. data.equipPvpLoss ..
"%, #f75f5f} chance that you will lose your equipped container on your next death.")

BlessingController.ui.promotionStatus.equipmentLoss:setColoredText(
"- There is a {" .. data.equipPveLoss .. "%, #f75f5f} chance that you will lose items upon your next death.")

BlessingController.ui.blessingHistory:getChildByIndex(1):destroyChildren()
local row2 = g_ui.createWidget("historyData", BlessingController.ui.blessingHistory:getChildByIndex(1))
row2:setBackgroundColor("#363636")
row2.rank:setText("date")
row2.name:setText("Event")
row2.rank:setColor("#c0c0c0")
row2.name:setColor("#c0c0c0")

for index, entry in ipairs(data.logs) do
local row = g_ui.createWidget("historyData", BlessingController.ui.blessingHistory:getChildByIndex(1))
local date = os.date("%Y-%m-%d, %H:%M:%S", entry.timestamp)
row:setBackgroundColor(index % 2 == 0 and "#ffffff12" or "#00000012")
row.rank:setText(date)
row.name:setText(entry.historyMessage)
end

kokekanon marked this conversation as resolved.
Show resolved Hide resolved
end
9 changes: 9 additions & 0 deletions modules/game_blessing/blessing.otmod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Module
name: game_blessing
description: game_blessing
author: game_blessing
website: game_blessing
scripts: [ blessing.lua ]
sandboxed: true
@onLoad: BlessingController:init()
@onUnload: BlessingController:terminate()
Binary file added modules/game_blessing/images/1.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 modules/game_blessing/images/1_on.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 modules/game_blessing/images/2.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 modules/game_blessing/images/2_on.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 modules/game_blessing/images/3.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 modules/game_blessing/images/3_on.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 modules/game_blessing/images/4.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 modules/game_blessing/images/4_on.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 modules/game_blessing/images/5.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 modules/game_blessing/images/5_on.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 modules/game_blessing/images/6.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 modules/game_blessing/images/6_on.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 modules/game_blessing/images/7.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 modules/game_blessing/images/7_on.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 modules/game_blessing/images/8.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 modules/game_blessing/images/8_on.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 modules/game_blessing/images/getpremium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions modules/game_blessing/style.otui
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
historyData < UIWidget
height: 16
Label
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom : parent.bottom
id: rank
width: 150
!text: tr('1')
text-align: center
color: #dfdfdfcf
phantom: false
margin-left: 4

VerticalSeparator
id: separator
anchors.top: parent.top
anchors.left: parent.left
anchors.bottom: parent.bottom
margin-top: -1
margin-bottom: -1
margin-left: 155

Label
anchors.top: parent.top
anchors.left: prev.right
anchors.bottom : parent.bottom
id: name
width: 216
!text: tr('-')
text-align: left
color: #ff0000cf
phantom: true
margin-left: 5

kokekanon marked this conversation as resolved.
Show resolved Hide resolved
blessingTEST < UIWidget
background-color: alpha
height: 62
width: 70
focusable: true
text-align: left
UIWidget
id: enabled
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
margin-top: -10
margin-left: 3
Label
id: text
!text: tr('loooooong text')
text-align: center
margin-top: 5
width: 65
anchors.left: prev.left
anchors.top: prev.bottom

image-source: /game_blessing/images/blessingContainer
focusable: false

BlessingButton < UIButton
size: 128 37
image-source: /game_blessing/images/getpremium
image-clip: 0 0 128 37
image-border: 3
@onClick: modules.game_shop.toggle()

$pressed:
image-clip: 0 37 128 37
$!on:
image-clip: 0 74 128 37
$disabled:
color: #dfdfdf88
opacity: 0.8

1 change: 1 addition & 0 deletions modules/game_interface/interface.otmod
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ Module
- game_shop
- game_screenshot
- game_highscore
- game_blessing
@onLoad: init()
@onUnload: terminate()
4 changes: 2 additions & 2 deletions modules/game_inventory/inventory.otui
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ PhantomMiniWindow
anchors.left: changeSize.right
margin-left: 3
size: 12 12

@onClick: modules.game_blessing.toggle()
$pressed !disabled:
image-clip: 12 0 12 12

Expand Down Expand Up @@ -536,7 +536,7 @@ PhantomMiniWindow
anchors.left: changeSize.left
margin-top: 3
size: 12 12

@onClick: modules.game_blessing.toggle()
$pressed !disabled:
image-clip: 12 0 12 12

Expand Down
8 changes: 8 additions & 0 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,3 +1726,11 @@ void Game::imbuementDurations(bool isOpen)
return;
m_protocolGame->sendImbuementDurations(isOpen);
}

void Game::requestBless()
{
if (!canPerformGameAction())
return;

m_protocolGame->sendRequestBless();
}
Loading
Loading