Skip to content

Commit b3b37c8

Browse files
committed
Add config value to specify assets owned,
- Added 2 config options to calculate current assets value + assets profit - Fix icons not loading if using CoinId instead of CoinSymbol - Bump to new version
1 parent c1d9ee5 commit b3b37c8

File tree

9 files changed

+119
-13
lines changed

9 files changed

+119
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ETH: 0x1125207ae7d169eb623fa228e5b2c48a6b6482d9
103103
## MIT License
104104

105105
```
106-
Copyright (c) 2018-2021 Bojan Petkovski
106+
Copyright (c) 2018-2022 Bojan Petkovski
107107
108108
Permission is hereby granted, free of charge, to any person obtaining a copy
109109
of this software and associated documentation files (the "Software"), to deal

pbojan/@Resources/CryptoCoins.ini

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Name=CryptoCoins
1212
Author=Bojan Petkovski (https://github.com/pbojan)
1313
Information=Skin that displays the current price of any cryptocoin and their daily percent changes.
1414
License=MIT
15-
Version=1.6
15+
Version=1.7
1616

1717
[Variables]
18-
Version=1.6
18+
Version=1.7
1919

2020
; ----------------------------------
2121
; Measures
@@ -112,6 +112,14 @@ IfAboveAction=[!SetOption MeterChanges7D FontColor 5eb160][!Redraw]
112112
IfBelowValue=0
113113
IfBelowAction=[!SetOption MeterChanges7D FontColor ff4b48][!Redraw]
114114

115+
[MeasureAssetsOwned]
116+
Measure=String
117+
String=-
118+
119+
[MeasureAssetsIncrease]
120+
Measure=String
121+
String=-
122+
115123
[MeasureCoinLastUpdated]
116124
Measure=WebParser
117125
URL=[MeasureCoinData]
@@ -169,6 +177,15 @@ X=190
169177
W=190
170178
H=20
171179

180+
[StyleAssetsValue]
181+
StringAlign=CenterCenter
182+
FontColor=73c4ff
183+
FontSize=10
184+
Padding=0,0,0,5
185+
X=105
186+
W=190
187+
H=15
188+
172189
; ----------------------------------
173190
; METERS display images, text, bars, etc.
174191
; ----------------------------------
@@ -181,7 +198,6 @@ DynamicVariables=1
181198

182199
[MeterIcon]
183200
Meter=Image
184-
ImageName=#@#icons/#CoinSymbol#.png
185201
X=10
186202
Y=10
187203
W=46
@@ -250,17 +266,33 @@ MeasureName=MeasureCoinChange7DRounded
250266
Y=140
251267
Text=%1%
252268

269+
[MeterAssetsOwned]
270+
Meter=String
271+
MeterStyle=StyleFont | StyleAssetsValue
272+
MeasureName=MeasureAssetsOwned
273+
Y=5R
274+
Text=%1
275+
Hidden=1
276+
277+
[MeterAssetsIncrease]
278+
Meter=String
279+
MeterStyle=StyleFont | StyleAssetsValue
280+
MeasureName=MeasureAssetsIncrease
281+
Y=0R
282+
Text=%1
283+
Hidden=1
284+
253285
[MeterLastUpdated]
254286
Meter=String
255287
MeterStyle=StyleFont | StyleUpdatedAt
256288
MeasureName=MeasureCoinLastUpdatedFormatted
257-
Y=165
289+
Y=5R
258290

259291
[MeterDonateIcon]
260292
Meter=Image
261293
ImageName=#@#donate.png
262294
X=5
263-
Y=145
295+
Y=-45R
264296
W=28
265297
H=28
266298
PreserveAspectRatio=1
@@ -275,7 +307,7 @@ Hidden=1
275307
Meter=Image
276308
ImageName=#@#upgrade.png
277309
X=5
278-
Y=145
310+
Y=0R
279311
W=28
280312
H=28
281313
PreserveAspectRatio=1

pbojan/@Resources/scripts/Helpers.lua

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ function Round(num)
3434
return string.format('%.' .. idp .. 'f', num)
3535
end
3636

37+
function RoundWithPrecision(num, idp)
38+
if num == '' then
39+
return num
40+
end
41+
42+
num = tonumber(num)
43+
44+
return string.format('%.' .. idp .. 'f', num)
45+
end
46+
3747
function RoundPercent(num)
3848
if num == '' then
3949
return num
@@ -67,7 +77,11 @@ end
6777
function OnRequestParsed()
6878
local MeasureCoinLastUpdated = SKIN:GetMeasure('MeasureCoinLastUpdated')
6979
local date = MeasureCoinLastUpdated:GetStringValue()
80+
local coinSymbol = SKIN:GetMeasure('MeasureCoinSymbol'):GetStringValue()
7081

82+
-- Set icon based on the symbol
83+
SKIN:Bang('!SetOption', 'MeterIcon', 'ImageName', '#@#icons/' .. coinSymbol .. '.png')
84+
7185
-- Set formatted date
7286
SKIN:Bang('!SetOption', 'MeasureCoinLastUpdatedFormatted', 'String', FormatDate(date))
7387

@@ -83,6 +97,30 @@ function OnRequestParsed()
8397

8498
local MeasureCoinChange7D = SKIN:GetMeasure('MeasureCoinChange7D')
8599
SKIN:Bang('!SetOption', 'MeasureCoinChange7DRounded', 'String', RoundPercent(MeasureCoinChange7D:GetStringValue()))
100+
101+
assetsOwned = tonumber(SKIN:GetVariable('AssetsOwned'))
102+
assetsValue = tonumber(SKIN:GetVariable('AssetsValue'))
103+
104+
if assetsOwned then
105+
currency = SKIN:GetVariable('Currency')
106+
107+
-- Set assets owned and total current value
108+
SKIN:Bang('!SetOption', 'MeasureAssetsOwned', 'String', assetsOwned .. ' ' .. coinSymbol .. ' | ' .. currency .. ' ' .. Round(assetsOwned * tonumber(MeasureCoinPrice:GetStringValue())))
109+
SKIN:Bang('!ShowMeter', 'MeterAssetsOwned')
110+
111+
-- If assets value is set also show profit percent
112+
if assetsValue then
113+
assetsProfit = assetsOwned * tonumber(MeasureCoinPrice:GetStringValue()) - assetsValue
114+
assetsIncrease = (assetsProfit / assetsValue) * 100
115+
116+
SKIN:Bang('!SetOption', 'MeasureAssetsIncrease', 'String', currency .. ' ' .. RoundWithPrecision(assetsProfit, 2) .. ' | ' .. RoundPercent(assetsIncrease) .. '%')
117+
SKIN:Bang('!SetOption', 'MeterAssetsIncrease', 'FontColor', '5eb160')
118+
if assetsProfit < 0 then
119+
SKIN:Bang('!SetOption', 'MeterAssetsIncrease', 'FontColor', 'ff4b48')
120+
end
121+
SKIN:Bang('!ShowMeter', 'MeterAssetsIncrease')
122+
end
123+
end
86124
end
87125

88126
function GetTimezoneDiff()

pbojan/CryptoCoins/Bitcoin/Bitcoin.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

pbojan/CryptoCoins/BitcoinCash/BitcoinCash.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

pbojan/CryptoCoins/Etherium/Ethereum.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

pbojan/CryptoCoins/Litecoin/Litecoin.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

pbojan/CryptoCoins/MaidSafeCoin/MaidSafeCoin.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

pbojan/CryptoCoins/Ripple/Ripple.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@ FontName=Calibri
3333

3434
; The update time of the data on the widget in seconds. Default is 1800 sec (30 minutes).
3535
; NOTE: Using lower value will use more resources on your computer and API credits.
36-
UpdateTime=1800
36+
UpdateTime=1800
37+
38+
; How many of the cryptocurrency assets do you own? Used to show your current value. Used together with AssetsValue field.
39+
;AssetsOwned=0.00
40+
41+
; For how much did you buy them? Used to calculate profits. You can leave it 0 if you e.g. mined them. Used together with AssetsOwned field.
42+
;AssetsValue=0.00

0 commit comments

Comments
 (0)