-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
EgzoT
authored
Dec 19, 2017
1 parent
f6d090b
commit 4fa66dd
Showing
3 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
mapPanel = modules.game_interface.getMapPanel() | ||
gameRootPanel = modules.game_interface.gameBottomPanel | ||
gameLeftPanel = modules.game_interface.getLeftPanel() | ||
|
||
function currentViewMode() | ||
return modules.game_interface.currentViewMode | ||
end | ||
|
||
healthCircle = nil | ||
manaCircle = nil | ||
|
||
g_ui.loadUI('game_healthcircle') | ||
|
||
healthCircleFront = nil | ||
manaCircleFront = nil | ||
|
||
function init() | ||
healthCircle = g_ui.createWidget('HealthCircle', mapPanel) | ||
manaCircle = g_ui.createWidget('ManaCircle', mapPanel) | ||
|
||
healthCircleFront = g_ui.createWidget('HealthCircleFront', mapPanel) | ||
manaCircleFront = g_ui.createWidget('ManaCircleFront', mapPanel) | ||
|
||
whenMapResizeChange() | ||
initOnHpAndMpChange() | ||
initOnGeometryChange() | ||
initOnLoginChange() | ||
end | ||
|
||
function terminate() | ||
healthCircle:destroy() | ||
manaCircle:destroy() | ||
healthCircleFront:destroy() | ||
manaCircleFront:destroy() | ||
|
||
terminateOnHpAndMpChange() | ||
terminateOnGeometryChange() | ||
terminateOnLoginChange() | ||
end | ||
|
||
------------------------------------------------- | ||
--Scripts---------------------------------------- | ||
------------------------------------------------- | ||
|
||
function initOnHpAndMpChange() | ||
connect(LocalPlayer, { onHealthChange = whenHealthChange, | ||
onManaChange = whenManaChange }) | ||
end | ||
|
||
function terminateOnHpAndMpChange() | ||
disconnect(LocalPlayer, { onHealthChange = whenHealthChange, | ||
onManaChange = whenManaChange }) | ||
end | ||
|
||
function initOnGeometryChange() | ||
connect(gameRootPanel, { onGeometryChange = whenMapResizeChange }) | ||
end | ||
|
||
function terminateOnGeometryChange() | ||
disconnect(gameRootPanel, { onGeometryChange = whenMapResizeChange }) | ||
end | ||
|
||
function initOnLoginChange() | ||
connect(g_game, { onGameStart = whenMapResizeChange }) | ||
end | ||
|
||
function terminateOnLoginChange() | ||
disconnect(g_game, { onGameStart = whenMapResizeChange }) | ||
end | ||
|
||
function whenHealthChange() | ||
if g_game.isOnline() then | ||
local Yhppc = math.floor(208 * (1 - (g_game.getLocalPlayer():getHealthPercent() / 100))) | ||
local rect = { x = 0, y = Yhppc, width = 63, height = 208 } | ||
healthCircleFront:setImageClip(rect) | ||
if currentViewMode() ~= 2 then | ||
healthCircleFront:setY(mapPanel:getHeight() / 2 - healthCircle:getHeight() / 2 + 30 + Yhppc) | ||
else | ||
healthCircleFront:setY(mapPanel:getHeight() / 2 - healthCircle:getHeight() / 2 + 0 + Yhppc) | ||
end | ||
end | ||
end | ||
|
||
function whenManaChange() | ||
if g_game.isOnline() then | ||
local Ymppc = math.floor(208 * (1 - (math.floor((g_game.getLocalPlayer():getMaxMana() - (g_game.getLocalPlayer():getMaxMana() - g_game.getLocalPlayer():getMana())) * 100 / g_game.getLocalPlayer():getMaxMana()) / 100))) | ||
local rect = { x = 0, y = Ymppc, width = 63, height = 208 } | ||
manaCircleFront:setImageClip(rect) | ||
if currentViewMode() ~= 2 then | ||
manaCircleFront:setY(mapPanel:getHeight() / 2 - manaCircle:getHeight() / 2 + 30 + Ymppc) | ||
else | ||
manaCircleFront:setY(mapPanel:getHeight() / 2 - manaCircle:getHeight() / 2 + 0 + Ymppc) | ||
end | ||
end | ||
end | ||
|
||
function whenMapResizeChange() | ||
if g_game.isOnline() then | ||
whenHealthChange() | ||
whenManaChange() | ||
|
||
if currentViewMode() == 2 then | ||
healthCircleFront:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150) | ||
manaCircleFront:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + 0) | ||
|
||
healthCircle:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150) | ||
manaCircle:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + 0) | ||
|
||
healthCircle:setY(mapPanel:getHeight() / 2 - healthCircle:getHeight() / 2 + 0) | ||
manaCircle:setY(mapPanel:getHeight() / 2 - manaCircle:getHeight() / 2 + 0) | ||
elseif gameLeftPanel:isOn() then | ||
healthCircleFront:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150 + gameLeftPanel:getWidth()) | ||
manaCircleFront:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + gameLeftPanel:getWidth()) | ||
|
||
healthCircle:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150 + gameLeftPanel:getWidth()) | ||
manaCircle:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + gameLeftPanel:getWidth()) | ||
|
||
healthCircle:setY(mapPanel:getHeight() / 2 - healthCircle:getHeight() / 2 + 30) | ||
manaCircle:setY(mapPanel:getHeight() / 2 - manaCircle:getHeight() / 2 + 30) | ||
else | ||
healthCircleFront:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150) | ||
manaCircleFront:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + 0) | ||
|
||
healthCircle:setX(mapPanel:getWidth() / 2 + healthCircle:getWidth() / 2 - 150) | ||
manaCircle:setX(mapPanel:getWidth() / 2 + manaCircle:getWidth() / 2 + 0) | ||
|
||
healthCircle:setY(mapPanel:getHeight() / 2 - healthCircle:getHeight() / 2 + 30) | ||
manaCircle:setY(mapPanel:getHeight() / 2 - manaCircle:getHeight() / 2 + 30) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Module | ||
name: game_healthcircle | ||
description: Draw health circle and mana circle in game map. | ||
author: Egzo (EgzoT), Tekadon2 (Tekadon58) [graphics] | ||
website: https://github.com/EgzoT/-OTClient-Mod-health_and_mana_circle | ||
version: 1.0 | ||
|
||
autoload: true | ||
autoload-priority: 1000 | ||
sandboxed: true | ||
dependencies: [ game_interface ] | ||
scripts: [ game_healthcircle ] | ||
@onLoad: init() | ||
@onUnload: terminate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
HealthCircle < UIProgressBar | ||
image-source: /game_healthcircle/img_game_healthcircle/health_circle | ||
opacity: 0.7 | ||
phantom: true | ||
|
||
ManaCircle < UIProgressBar | ||
image-source: /game_healthcircle/img_game_healthcircle/mana_circle | ||
opacity: 0.7 | ||
phantom: true | ||
|
||
HealthCircleFront < UIProgressBar | ||
image-source: /game_healthcircle/img_game_healthcircle/health_circle_top | ||
opacity: 0.7 | ||
phantom: true | ||
|
||
ManaCircleFront < UIProgressBar | ||
image-source: /game_healthcircle/img_game_healthcircle/mana_circle_top | ||
opacity: 0.7 | ||
phantom: true |