2121//
2222
2323// / <summary>
24- // / Retrieves the option defined in the skin file
24+ // / Retrieves an option of the plugin script measure
2525// / </summary>
2626// / <param name="rm">Pointer to the plugin measure</param>
27- // / <param name="option">Option name to be read from skin </param>
27+ // / <param name="option">Option name</param>
2828// / <param name="defValue">Default value for the option if it is not found or invalid</param>
2929// / <param name="replaceMeasures">If true, replaces section variables in the returned string</param>
3030// / <returns>Returns the option value as a string (LPCWSTR)</returns>
3333// / PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
3434// / {
3535// / LPCWSTR value = RmReadString(rm, L"Value", L"DefaultValue");
36- // / LPCWSTR action = RmReadString(rm, L"Action", L"", FALSE); // [MeasureNames] will be parsed/replaced when the action is executed with RmExecute
3736// / }
3837// / </code>
3938// / </example>
40- #ifdef __cplusplus
4139LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void * rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE );
40+
41+ // / <summary>
42+ // / Retrieves an option of a meter/measure
43+ // / </summary>
44+ // / <remarks>In older Rainmeter versions without support for this API, always returns the default value</remarks>
45+ // / <param name="rm">Pointer to the plugin measure</param>
46+ // / <param name="section">Meter/measure section name</param>
47+ // / <param name="option">Option name</param>
48+ // / <param name="defValue">Default value for the option if it is not found or invalid</param>
49+ // / <param name="replaceMeasures">If true, replaces section variables in the returned string</param>
50+ // / <returns>Returns the option value as a string (LPCWSTR)</returns>
51+ // / <example>
52+ // / <code>
53+ // / PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
54+ // / {
55+ // / LPCWSTR value = RmReadStringFromSection(rm, L"MySection", L"Value", L"DefaultValue");
56+ // / }
57+ // / </code>
58+ // / </example>
59+ #ifdef LIBRARY_EXPORTS
60+ LIBRARY_EXPORT LPCWSTR __stdcall RmReadStringFromSection (void * rm, LPCWSTR section, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE );
4261#else
43- LIBRARY_EXPORT LPCWSTR __stdcall RmReadString (void * rm, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures);
44- #endif // __cplusplus
62+ inline LPCWSTR RmReadStringFromSection (void * rm, LPCWSTR section, LPCWSTR option, LPCWSTR defValue, BOOL replaceMeasures = TRUE )
63+ {
64+ typedef LPCWSTR (__stdcall* RmReadStringFromSectionFunc)(void *, LPCWSTR, LPCWSTR, LPCWSTR, BOOL);
65+ static auto delayedFunc = (RmReadStringFromSectionFunc)GetProcAddress (GetModuleHandle (L" Rainmeter.dll" ), " RmReadStringFromSection" );
66+ if (delayedFunc)
67+ {
68+ return delayedFunc (rm, section, option, defValue, replaceMeasures);
69+ }
70+
71+ return defValue;
72+ }
73+ #endif
4574
4675// / <summary>
47- // / Parses any formulas in the option (use RmReadDouble/RmReadInt instead)
76+ // / Retrieves an option of the plugin script measure as a number after parsing possible formula
4877// / </summary>
4978// / <param name="rm">Pointer to the plugin measure</param>
50- // / <param name="option">Option name to be read from skin </param>
79+ // / <param name="option">Option name</param>
5180// / <param name="defValue">Default value for the option if it is not found, invalid, or a formula could not be parsed</param>
5281// / <returns>Returns the option value as an double</returns>
5382// / <example>
@@ -60,6 +89,83 @@ LIBRARY_EXPORT LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR
6089// / </example>
6190LIBRARY_EXPORT double __stdcall RmReadFormula (void * rm, LPCWSTR option, double defValue);
6291
92+ // / <summary>
93+ // / Retrieves an option of a meter/measure as a number after parsing possible formula
94+ // / </summary>
95+ // / <remarks>In older Rainmeter versions without support for this API, always returns the default value</remarks>
96+ // / <param name="rm">Pointer to the plugin measure</param>
97+ // / <param name="section">Meter/measure section name</param>
98+ // / <param name="option">Option name</param>
99+ // / <param name="defValue">Default value for the option if it is not found, invalid, or a formula could not be parsed</param>
100+ // / <returns>Returns the option value as an double</returns>
101+ // / <example>
102+ // / <code>
103+ // / PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
104+ // / {
105+ // / double value = RmReadFormulaFromSection(rm, L"MySection", L"Value", 20);
106+ // / }
107+ // / </code>
108+ // / </example>
109+ #ifdef LIBRARY_EXPORTS
110+ LIBRARY_EXPORT double __stdcall RmReadFormulaFromSection (void * rm, LPCWSTR section, LPCWSTR option, double defValue);
111+ #else
112+ inline double RmReadFormulaFromSection (void * rm, LPCWSTR section, LPCWSTR option, double defValue)
113+ {
114+ typedef double (__stdcall* RmReadFormulaFromSectionFunc)(void *, LPCWSTR, LPCWSTR, double );
115+ static auto delayedFunc = (RmReadFormulaFromSectionFunc)GetProcAddress (GetModuleHandle (L" Rainmeter.dll" ), " RmReadFormulaFromSection" );
116+ if (delayedFunc)
117+ {
118+ return delayedFunc (rm, section, option, defValue);
119+ }
120+
121+ return defValue;
122+ }
123+ #endif
124+
125+ // / <summary>
126+ // / Retrieves the option defined in a section and converts it to an integer.
127+ // / </summary>
128+ // / <remarks>If the option is a formula, the returned value will be the result of the parsed formula.</remarks>
129+ // / <param name="rm">Pointer to the plugin measure</param>
130+ // / <param name="section">Meter/measure section name</param>
131+ // / <param name="option">Option name</param>
132+ // / <param name="defValue">Default value if the option is not found or invalid</param>
133+ // / <returns>Returns the option value as an integer</returns>
134+ // / <example>
135+ // / <code>
136+ // / PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
137+ // / {
138+ // / int value = RmReadIntFromSection(rm, L"Section", L"Option", 20);
139+ // / }
140+ // / </code>
141+ // / </example>
142+ __inline int RmReadIntFromSection (void * rm, LPCWSTR section, LPCWSTR option, int defValue)
143+ {
144+ return (int )RmReadFormulaFromSection (rm, section, option, defValue);
145+ }
146+
147+ // / <summary>
148+ // / Retrieves the option defined in a section and converts it to a double.
149+ // / </summary>
150+ // / <remarks>If the option is a formula, the returned value will be the result of the parsed formula.</remarks>
151+ // / <param name="rm">Pointer to the plugin measure</param>
152+ // / <param name="section">Meter/measure section name</param>
153+ // / <param name="option">Option name</param>
154+ // / <param name="defValue">Default value if the option is not found or invalid</param>
155+ // / <returns>Returns the option value as a double</returns>
156+ // / <example>
157+ // / <code>
158+ // / PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
159+ // / {
160+ // / double value = RmReadDoubleFromSection(rm, L"Section", L"Option", 20.0);
161+ // / }
162+ // / </code>
163+ // / </example>
164+ __inline double RmReadDoubleFromSection (void * rm, LPCWSTR section, LPCWSTR option, double defValue)
165+ {
166+ return RmReadFormulaFromSection (rm, section, option, defValue);
167+ }
168+
63169// / <summary>
64170// / Returns a string, replacing any variables (or section variables) within the inputted string
65171// / </summary>
0 commit comments