It is currently September 17th, 2021, 12:56 pm

My first RainMeter module [StarCraft II Badge]

RSS, ATOM and other feeds, GMail, Stocks, any information retrieved from the internet
User avatar
Hydra
Posts: 12
Joined: January 26th, 2012, 11:50 pm
Location: Canada

My first RainMeter module [StarCraft II Badge]

Post by Hydra »

So here's my first RainMeter module that I've ever made. I'm a StarCraft II fanatic so I made this to display your 1v1 division badge, and on mouse-over it displays division name/division rank/games won. It pulls the information from your battle.net profile page. :)

Image

Image

Overall I'm pretty happy with the concept, but I feel like the code is crap. I use a Lua script where it's probably not necessary. But then again I just adore Lua. :oops:
I don't suffer from insanity, I enjoy it.
User avatar
Mordasius
Posts: 1069
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: My first RainMeter module [StarCraft II Badge]

Post by Mordasius »

Nice job that I'm sure will attract the interest of Starcraft aficionados.

I jumped through similar hoops making a skin for a friend but used http://sc2ranks.com/sea/#IDNumber#/#CharacterName# for the URL rather than Battle.net because that is more applicable over here. You haven't shared your code, but would I be right in guessing you had to use LUA script to apply ImageCrop to your equivalent of http://sc2ranks.com/images/leagues/platinum.png? LUA certainly seemed the easiest way to do it in my case.
User avatar
Hydra
Posts: 12
Joined: January 26th, 2012, 11:50 pm
Location: Canada

Re: My first RainMeter module [StarCraft II Badge]

Post by Hydra »

Nope, I actually cut out all the images in Photoshop and just have them in a folder. :???:

Actually what the lua is for is because the webparser returns proper "Win" values for bronze through diamond divisions, but for master/grandmaster it was picking up wierd values. I wasn't able to find a logical reason for it, so what I did was sort of... trim the string it was returning via Lua.

I'm sure i'll be laughed at by more savvy coders, but I didn't know how to fix this within Rainmeter itself, plus as I said I love Lua script, so this was my work-around for now.

Code: Select all

Update = function()
	local Badge = SKIN:GetMeasure("MeasureBadge"):GetStringValue()
	local Wins = SKIN:GetMeasure("MeasureWinsLua"):GetStringValue()
	
	if Badge:find("master") then -- Find Master/Grandmaster
		return Wins:match("%d+", (Wins:len() - 4))
	else
		return Wins
	end
end
I don't suffer from insanity, I enjoy it.
User avatar
Mordasius
Posts: 1069
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: My first RainMeter module [StarCraft II Badge]

Post by Mordasius »

Come on then Hydra.. lift your skirts and show us what you've got (as in the complete skin). I'm sure there are lots of us just waiting to wade in with suggestions :)
User avatar
Hydra
Posts: 12
Joined: January 26th, 2012, 11:50 pm
Location: Canada

Re: My first RainMeter module [StarCraft II Badge]

Post by Hydra »

Here's an upload if you'd like to see how the entire thing is set up: http://dl.dropbox.com/u/7035114/RankBadge.zip

And if you just want the .ini code:

Code: Select all

[Rainmeter]
Author=Hydra
Update=1000

[Metadata]
Name=RankBadge
Information=Display StarCraft 2 rank
License=None
Version=1.00

[Variables]
URL="http://us.battle.net/sc2/en/profile/3108735/1/oGsVINES/"

; Measures

[MeasureWeb]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=600
Url=#URL#
RegExp="(?siU)<span class="badge (.*)">.*<strong>Division:</strong> (.*)<br />"

[MeasureRankWeb]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=600
Url=#URL#
RegExp="(?siU)<strong>Rank:</strong> (.*)</div>"

[MeasureRankLua]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureRankWeb]
StringIndex=1

[MeasureRankScript]
Measure=Script
ScriptFile=Rank.lua

[MeasureWinsWeb]
Measure=Plugin
Plugin=Plugins\WebParser.dll
UpdateRate=600
Url=#URL#
RegExp="(?siU)<span class="totals">(.*) Wins</span>"

[MeasureWinsLua]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWinsWeb]
StringIndex=1

[MeasureWinsScript]
Measure=Script
ScriptFile=Masters.lua

[MeasureBadge]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeb]
StringIndex=1

[MeasureDivision]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=[MeasureWeb]
StringIndex=2

; Meters

[MeterBackground]
Meter=Image
X=1
Y=1
H=100
W=100

[MeterBadge]
MeasureName=MeasureBadge
MeasureName2=MeasureDivision
MeasureName3=MeasureRankScript
MeasureName4=MeasureWinsScript
Meter=Image
X=1
Y=1
ImageName=Images\%1.png
ToolTipText="Division: %2#CRLF#Rank: %3#CRLF#Wins: %4"
LeftMouseUpAction=!Execute ["#URL#"]
I would love some constructive ideas on cleaning this up, since i'm aware it's... well less than ideal.
I don't suffer from insanity, I enjoy it.
User avatar
Mordasius
Posts: 1069
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: My first RainMeter module [StarCraft II Badge]

Post by Mordasius »

Sorry for the delay in replying but other stuff grabbed a chunk of my time. My first comment would be that you seem to be using more WebParser measures than you really need to. I think you can just combine all the RegExp='s in [MeasureWeb], [MeasureRankWeb], [MeasureWinsWeb] in a single measure.

You mentioned that you'd used a "Lua script where it's probably not necessary. But then again I just adore Lua". I'm not much of a LUA programmer but I appreciate the way it can be integrated in Rainmeter skins, however, I don't think it is really needed in this case. On the positive side, I had always thought you could only have one LUA script per config, so you taught me something that I'm sure will come in useful at some time, Tnx.

As a result of your post I went back to my old Starcraft II profile skin and used some tips from the Rainmeter Forum post Workaround for Dynamic Variables in WebParser Plugin to produce an updated version without LUA and using http://battle.net rather than http://sc2ranks.com for most of the information. Note that this skin downloads the Portraits and Rank Badges from sc2ranks.com so you avoid all that Photoshop editing.

Code: Select all

[Rainmeter]
Author=Mordasius
Update=1000
MiddleMouseDownAction=!Refresh

[Metadata]
Name=SCProfile-2
Version=02022012
Description= Skin displays Starcraft II profile
License=Creative Commons Attribution-Noncommercial-Share Alike 3.0

[Variables]
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;http://sea.battle.net/sc2/en/profile/325603/1/Zettasun/
; Region=sea
; PlayerName=Zettasun
; PlayerNumber=325603
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;http://us.battle.net/sc2/en/profile/3108735/1/oGsVINES/
Region=us
PlayerName=oGsVINES
PlayerNumber=3108735
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
URLProfile=http://#Region#.battle.net/sc2/en/profile/#PlayerNumber#/1/#PlayerName#/
UpdateProfile=3600
MyRank=**Unknown**
PortraitPage=0                            

[TextStyle]
StringAlign=LEFT
StringStyle=BOLD
FontFace=Calibri
FontColor=ffffff
FontSize=10
Y=R
Antialias=1

[mGetRank]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#URLProfile#
RegExp="(?siU)<title>(.*) - StarCraft II.*<span class="badge badge-(.*) badge-medium-(.*)">"
StringIndex=2
FinishAction=!Execute [!WriteKeyValue Variables "MyRank" "[mGetRank]"][!WriteKeyValue mGetRank Disabled 1] [!WriteKeyValue mGetProfile Disabled 0] [!Refresh]
Disabled=0

[mGetProfile]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=#URLProfile#
RegExp="(?siU)<title>(.*) - StarCraft II.*<span class="icon-frame ".*portraits/(.*)-90.jpg.*\)(.*)px(.*)px.*<span class="badge badge-(.*) badge-medium-(.*)">.*Division:</strong> (.*)<br />.*Rank:</strong>(.*)\n.*</div>.*<span class="totals">(.*)</span>.*<span class="totals">(.*)</span>"
StringIndex=1
FinishAction=!Execute [!EnableMeasureGroup Profiles] 
UpdateRate=#UpdateProfile#
Disabled=1

[mPlayerName]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=1
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mPortraitPage]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=2
Substitute=" ":""
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mPlayerPicX]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=3
Substitute=" ":"","-":""
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mPlayerPicY]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=4
Substitute=" ":"","-":""
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mBadgeName]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=5
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mBadgeLevel]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=6
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[cBadgePicY]
Measure=CALC
; Formula= (( [mBadgeLevel] -1)*105) - Large Badges
Formula= (( [mBadgeLevel] -1)*50)
DynamicVariables=1
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mDivision]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=7
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mRank]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=8
Substitute=" ":""
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mWon]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=9
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mGames]
Measure=Plugin
Plugin=Plugins\WebParser.dll
URL=[mGetProfile]
StringIndex=10
Substitute="No Games Played":"(?) Played"
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mGetPortraits]
Measure=Plugin
Plugin=WebParser
URL=http://us.battle.net/sc2/static/local-common/images/sc2/portraits/#PortraitPage#-90.jpg
Download=1
DownloadFile=Portraits.jpg
DynamicVariables=1
FinishAction=!Execute [!Showmeter PlayerAvatar] [!WriteKeyValue Variables "PortraitPage" "[mPortraitPage]"] 
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

[mGetBadges]
Measure=Plugin
Plugin=WebParser
URL=http://sc2ranks.com/images/leagues/#MyRank#.png
Download=1
DownloadFile=RankBadges.png
DynamicVariables=1
FinishAction=!Execute [!WriteKeyValue mGetRank Disabled 0] [!WriteKeyValue mGetProfile Disabled 1]
UpdateRate=#UpdateProfile#
Group=Profiles
Disabled=1

;_________________________________________
[BackGround]
Meter=String
W=77
H=77
SolidColor=0066cc
Text=" Updating...."
Update=-1

[PlayerAvatar]
Meter=IMAGE
ImageName="#CURRENTPATH#DownloadFile\Portraits.jpg"
X=1
Y=1
LeftMouseUpAction=#URLProfile#
MouseOverAction=!Execute [!ShowMeterGroup Stats] [!Update]
MouseLeaveAction=!Execute [!HideMeterGroup Stats] [!Update]
ImageCrop= [mPlayerPicX], [mPlayerPicY], 90, 90
H=75
W=75
DynamicVariables=1
Hidden=1

[PopUpBackGround]
Meter=Image
X=77
W=240
H=77
SolidColor=0066cc
Update=-1
Hidden=1
Group=Stats

[ShowPlayerTitle]
Meter=STRING
MeasureName=mPlayerName
MeterStyle=TextStyle
FontColor=f8d906
Fontsize=14
X=81
Y=0
Hidden=1
Group=Stats

[PlayerRankBadge]
Meter=IMAGE
ImageName="#CURRENTPATH#DownloadFile\RankBadges.png"
; ImageCrop= 0, [cBadgePicY], 100, 105 -- Large badges
ImageCrop= 100, [cBadgePicY], 45, 45
Y=25
X=80
DynamicVariables=1
Hidden=1
Group=Stats

[ShowPlayerRank]
Meter=STRING
MeterStyle=TextStyle
StringCase=PROPER
MeasureName=mBadgeName
X=130
Y=23
Hidden=1
Group=Stats

[ShowRankDivision]
Meter=STRING
MeterStyle=TextStyle
MeasureName=mRank
MeasureName2=mDivision
X=130
Text="Rank #%1 of %2"
Hidden=1
Group=Stats

[ShowPlayedWon]
Meter=STRING
MeterStyle=TextStyle
MeasureName=mWon
MeasureName2=mGames
X=130
Text="%1 : %2"
Hidden=1
Group=Stats
Untitled-1.jpg
You do not have the required permissions to view the files attached to this post.
User avatar
Hydra
Posts: 12
Joined: January 26th, 2012, 11:50 pm
Location: Canada

Re: My first RainMeter module [StarCraft II Badge]

Post by Hydra »

Hrmm, well there's a whole lot I can learn from this! Thank you for sharing. I plan to look this through and clean my own version up :)
I don't suffer from insanity, I enjoy it.
User avatar
Mordasius
Posts: 1069
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: My first RainMeter module [StarCraft II Badge]

Post by Mordasius »

Go for it Bro.. and don't forget that Zergs take Protoss most nights of the week :p
User avatar
Hydra
Posts: 12
Joined: January 26th, 2012, 11:50 pm
Location: Canada

Re: My first RainMeter module [StarCraft II Badge]

Post by Hydra »

Psh. Personally PvZ is my favorite match up, I find them easiest to beat :P
I don't suffer from insanity, I enjoy it.
User avatar
Mordasius
Posts: 1069
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: My first RainMeter module [StarCraft II Badge]

Post by Mordasius »

Zergling rush defeats all. Better Lie Down with your feet in the air and GG now rather than later :lol: