8000 UniqueRandom support for QuotePlugin by tjhrulz · Pull Request #147 · rainmeter/rainmeter · GitHub
[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniqueRandom support for QuotePlugin #147

Open
wants to merge 5 commits into
base: master
Choose a base branch
-->
from
Open

UniqueRandom support for QuotePlugin #147

wants to merge 5 commits into from

Conversation

tjhrulz
Copy link
Contributor
@tjhrulz tjhrulz commented Jan 25, 2018

This PR makes a few changes to QuotePlugin to support the UniqueRandom option found in other parts of Rainmeter. It also makes a few tweaks to make this possible.

To kind of summarize the changes:
Directory reading is basically unchanged we just move the vector indexes to another vector after they have been used and swap the vectors when all have been used.
File reading has pretty drastically changed however it is for the better and is 100% BWC. Before it would just chose a random char location find the next 2 separators and that would be the string. This meant that the first line had only a 1/charCount chance of being selected if our RNG was perfectly distributed. This also meant that separator pairs that were very spaced out would increase the likelihood of the next pair being selected. Now the separator count and locations are prechecked causing even odds and are checked on update to prevent pesky file changes and keep BWC. This then allows support for UniqueRandom to happen the same was as it is with directories.

Possible improvements:
Add directory watching so we can dynamically add or remove files instead of missing/loading files that no longer exist. (Not sure if we want to do this with how bad this stuff is in windows but it may be better when only looking for file add and remove)
DynamicVariables=1 should be discouraged slightly more than before but with some tweaks it may be possible to make them play nice.
Functions could be improved for better readability and closer code style.

Should have no impact on CPU or memory with the way I did it. However it
does not fix a long standing issue where new files are ignored and
deleted files are still attempted to be loaded. I may play around with
fixing those in the future.
Rewrote how the strings are selected so that every string in the file
has an equal likelyhood of being selected instead of heavily favoring a
the next string after having not had a seperator for a while. This is
done by preparsing the file similar to how directories are done so we
know where each different string starts and ends. With these changes
adding support for UniqueRandom is trivial.

Also will reread the file when the seperator is not where it is expected
to be. If this happens then it is safe to assume that the file has been
modified and needs reread. This maintains BWC for skins that modify text
files on the file that are used in quote meter.
Also fixes a few small oversites
General code cleanup and documentation as well.
Now does not cheat on function parameter passing by just passing the
measure. (We may still want to reduce the options into the one struct)
@tjhrulz
Copy link
Contributor Author
tjhrulz commented Feb 20, 2018

DV=1 and SetOption are now well handled. The method is it will detect if an option that is important has changed (Although brian you had a concern about false positives due to changes in case) and if it has it will then redo the setup process for the options and starts over.

I also stopped just passing the Measure struct for all the functions. It still is a little messy but it was pretty hairy in places to begin with.

I still have not added file watching but for the amount of work that would take for very little gain I don't know if it is worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0