UniqueRandom support for QuotePlugin #147
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.