It is currently March 29th, 2024, 2:29 pm

JRMLib Generation of skins with Java

Share and get help with Plugins and Addons
rxtd
Posts: 100
Joined: April 30th, 2017, 11:51 am

JRMLib Generation of skins with Java

Post by rxtd »

tl;dr: use it you want to autogenerate skins, mostly eliminate typos and use the power of IDEs.

Description
Well, "tl;dr;" section already said it: no more copy-pasting, no more typos, more type checking, easy editing.
I will probably add something to ease scaling, adding setting and other cool things. But my time is limited, so it won't happen anytime soon.

How to use
Download sources from github repository, open it as a project in your favourite IDE, write some code.
I didn't pack it as a .jar library. I probably should but I think it's not that necessary.


Structure of library
The main class is "Suite". It can contain several objects of class "Skin", some of which can be include-files. A Skin can contain several elements which are usually "Measure" or "Meter".
Suite should be written to a disk when all skins are created.
Skins have layers (queues), which are used to determine the order of sections in a .ini file.

Measures and meters are represented by implementations that match Rainmeter documentation. Name of classes match exactly, and option XYZ can be set using "setXYZ" method. Two exceptions are String meter and String measure. Although Java certainly allows me to have several classes with the same name, I really don't want to specify package every time I use any of these classes. So String meter is "Label" and String measure is "MString".
Bangs are represented as "Action". Bangs can be generated by "BangUtils" class.
Formulas are represented as "Formula".

All meter/measure methods take reference types, so you can pass null as a ref. In that case the option linked to that method is removed from the element. Sometimes, when the method takes several args, you can set some of them to null so only these options are removed.

Files other than skins are represented as "Resource". This is done for automation of resource management. You can create a resource linked to a file and this file will be copied to config or @Resources directory.
If you use plugins with specified files they will be copied to a "_Plugins" folder near @Resources.
All resources used in all skins can be listed after writing to disk. It can help not to forget about hand-managed resources.

Aside from what is listed in Rainmeter documentation the lib can be used for any plugins and scripts. There are some already: I added what I needed.

There are ways to avoid using of some parts of the lib:
Elements have "getParams" method that returns map of options. You can use it to specify options by hand in case you don't want to use a method or when a method does not exist.
Resources can be Virtual. In that case you only need to specify how to write a reference to it in skin. For example, when you want to copy files yourself.
There are "CustomScript" and "CustomPlugin" classes for scripts and plugins that are not implemented. It's better to write your own class though.
Bangs can be written by hand.
Formulas can be written by hand.

Any option can be changed in any time if there is a method to do so. All values that can be changed are read just before writing to disk.

Names of sections, variables, etc. can be generated automatically to avoid aliases. But it's always better to specify a human-readable name even if you use autogeneration for names.
Q&A
Is there some examples how to write something?
I created this lib for my skin-pack. It can be found here, and here is the result.
You can create some simpler examples, if you want. I don't really understand what these examples should contain because for me it is all simple. I will leave a link to your examples, if you write any.

Why can't I find X in this lib?
Well, it's either you didn't search properly or it is not implemented.
I believe I implementer everything that is listed in Rainmeter documentation (as of 2018-11-01) except for plugins (and maybe some bangs).
Ask me about X, I will say where it is, or add it when I have time.

Can you rewrite skin X using your lib?
I can but I won't. I don't have much spare time.
But I will answer your questions if you will rewrite it yourself.

Why Java? I want C#/python/lua/etc.
I like Java and I know it better than other languages.
If you want, you can write your analogue of my lib.

Why did you create it? There already exist some other tool for automated skin generation.
Wow, really? I didn't find anything like this the time I stared writing my lib.
I saw that there are snippets for skins for different text editors and also some syntax highlighting but that's not automation.
I also saw that some authors automate their skin creation with scripts. I think that it isn't very convenient.

I wan to help, what can I do?
If you have spare time but are not sure if you can write decent code you can help me with documentation. It's almost completely missing. If you at least copy it from Rainmeter docs and link it to existing classes it would be much appreciated.
If you found a bug write me about it.
If you have written an implementation for something missing make a pull-request on github.
2018-11-05_02-26-53.png

I hope there is at least one person who will find it interesting :)
You do not have the required permissions to view the files attached to this post.
xxxxx
Posts: 1
Joined: April 15th, 2019, 11:20 pm

Re: JRMLib Generation of skins with Java

Post by xxxxx »

I think it's interesting, but I use C++ :(