-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
5dc241b
commit 445d9f0
Showing
4 changed files
with
177 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,52 @@ | ||
[Rainmeter] | ||
Update=1000 | ||
BackgroundMode=2 | ||
SolidColor=255,255,255,150 | ||
|
||
[Metadata] | ||
Name=SkinFound | ||
Author=NS Tech Bytes | ||
Version=1.0 | ||
Description=Checks if specific skins exist in the Rainmeter skins folder using the SkinFound plugin. | ||
License=Appache 2.0 | ||
|
||
[Variables] | ||
SkinList=YourBar | Illustro | MiniSnap | ||
|
||
[mSkinFoundWhole] | ||
Measure=Plugin | ||
Plugin=SkinFound.dll | ||
SkinName=#SkinList# | ||
Output=Whole | ||
DynamicVariables=1 | ||
OnUpdateAction=[!Log "[mSkinFoundWhole]"] | ||
|
||
[mSkinFoundNameOnly] | ||
Measure=Plugin | ||
Plugin=SkinFound.dll | ||
SkinName=#SkinList# | ||
Output=NameOnly | ||
DynamicVariables=1 | ||
OnUpdateAction=[!Log "[mSkinFoundNameOnly]"] | ||
|
||
[TextWhole] | ||
Meter=String | ||
MeasureName=mSkinFoundWhole | ||
X=10 | ||
Y=10 | ||
FontColor=10,10,10 | ||
FontSize=12 | ||
Text="Full Status: #CRLF#[mSkinFoundWhole]" | ||
DynamicVariables=1 | ||
Antialias=1 | ||
|
||
[TextNameOnly] | ||
Meter=String | ||
MeasureName=mSkinFoundNameOnly | ||
X=10 | ||
Y=100 | ||
FontColor=10,10,10 | ||
FontSize=12 | ||
Text="Available Skins: #CRLF#[mSkinFoundNameOnly]" | ||
DynamicVariables=1 | ||
Antialias=1 |
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,125 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using Rainmeter; | ||
|
||
namespace PluginSkinFound | ||
{ | ||
public class Measure | ||
{ | ||
private string[] skinNames; | ||
private string skinsFolderPath; | ||
private string outputFormat = "Whole"; | ||
|
||
public void Reload(API api) | ||
{ | ||
string skinNamesSetting = api.ReadString("SkinName", "").Trim(); | ||
outputFormat = api.ReadString("Output", "Whole").Trim(); | ||
|
||
// Retrieve the Skins directory path from the #SKINSPATH# variable | ||
skinsFolderPath = api.ReplaceVariables("#SKINSPATH#").Trim(); | ||
|
||
if (string.IsNullOrEmpty(skinNamesSetting)) | ||
{ | ||
api.Log(API.LogType.Error, "SkinFound.dll: No SkinName provided."); | ||
skinNames = Array.Empty<string>(); | ||
} | ||
else | ||
{ | ||
// Split skin names and remove any extra spaces around them | ||
skinNames = skinNamesSetting.Split('|'); | ||
for (int i = 0; i < skinNames.Length; i++) | ||
{ | ||
skinNames[i] = skinNames[i].Trim(); | ||
} | ||
} | ||
} | ||
|
||
public string CheckSkinsExist(API api) | ||
{ | ||
if (skinNames == null || skinNames.Length == 0) | ||
{ | ||
return "No skins specified."; | ||
} | ||
|
||
string result = ""; | ||
foreach (string skin in skinNames) | ||
{ | ||
string skinPath = Path.Combine(skinsFolderPath, skin); | ||
bool skinExists = Directory.Exists(skinPath); | ||
|
||
if (outputFormat.Equals("NameOnly", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
if (skinExists) | ||
{ | ||
result += $"{skin}\n"; | ||
api.Log(API.LogType.Debug, $"SkinFound.dll: {skin} is available."); | ||
} | ||
} | ||
else // Whole format | ||
{ | ||
result += $"{skin}: {(skinExists ? 1 : 0)}\n"; | ||
api.Log(API.LogType.Debug, $"SkinFound.dll: {skin} is {(skinExists ? "available" : "NOT available")}."); | ||
} | ||
} | ||
return result.TrimEnd('\n'); | ||
} | ||
} | ||
|
||
public static class Plugin | ||
{ | ||
static IntPtr stringBuffer = IntPtr.Zero; | ||
|
||
[DllExport] | ||
public static void Initialize(ref IntPtr data, IntPtr rm) | ||
{ | ||
data = GCHandle.ToIntPtr(GCHandle.Alloc(new Measure())); | ||
} | ||
|
||
[DllExport] | ||
public static void Finalize(IntPtr data) | ||
{ | ||
if (data != IntPtr.Zero) | ||
{ | ||
GCHandle.FromIntPtr(data).Free(); | ||
} | ||
|
||
if (stringBuffer != IntPtr.Zero) | ||
{ | ||
Marshal.FreeHGlobal(stringBuffer); | ||
stringBuffer = IntPtr.Zero; | ||
} | ||
} | ||
|
||
[DllExport] | ||
public static void Reload(IntPtr data, IntPtr rm, ref double maxValue) | ||
{ | ||
var measure = (Measure)GCHandle.FromIntPtr(data).Target; | ||
var api = new API(rm); | ||
measure.Reload(api); | ||
} | ||
|
||
[DllExport] | ||
public static double Update(IntPtr data) | ||
{ | ||
return 0.0; | ||
} | ||
|
||
[DllExport] | ||
public static IntPtr GetString(IntPtr data) | ||
{ | ||
var measure = (Measure)GCHandle.FromIntPtr(data).Target; | ||
var api = new API(IntPtr.Zero); // Only used for logging purposes | ||
string result = measure.CheckSkinsExist(api); | ||
|
||
if (stringBuffer != IntPtr.Zero) | ||
{ | ||
Marshal.FreeHGlobal(stringBuffer); | ||
stringBuffer = IntPtr.Zero; | ||
} | ||
|
||
stringBuffer = Marshal.StringToHGlobalUni(result); | ||
return stringBuffer; | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.