-
Notifications
You must be signed in to change notification settings - Fork 329
tip of the day #6841
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
base: master
Are you sure you want to change the base?
tip of the day #6841
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6841 +/- ##
============================================
- Coverage 30.23% 30.21% -0.03%
+ Complexity 15803 15794 -9
============================================
Files 2885 2886 +1
Lines 283320 283445 +125
Branches 49340 49353 +13
============================================
- Hits 85674 85636 -38
- Misses 192047 192207 +160
- Partials 5599 5602 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On lower-resolution screens the tip is too large relative to the splash.
That would be due to the hints. What they do internally is essentially double the size of the render and scale it down. On HiDPI/Retina screens they show correctly. On "normal" screens they are twice the size. Or that is my theory on it anyways. |
Instead of rending to a Graphics context, why not render to a Swing object that can be inserted somewhere on the screen? |
Originally I did that with a layeredpane but I was getting very bad aliasing and ugly stroke. This was the most visually pleasing approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The license header needs to be updated to the correct version and you'll need to update latest master into this and fix the calls to the Internationalization class to I18N.
Almost there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces a new "Tip Of The Day" implementation with internationalization support and updates the screen resolution scaling utilities used within the UI.
- Added the TipOfTheDay class to display a daily/random tip with word wrapping and styling
- Refactored UIUtil to improve resolution scale factor computations and simplify splash component creation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
megamek/src/megamek/common/util/TipOfTheDay.java | Implements tip of the day functionality with i18n support and custom drawing |
megamek/src/megamek/client/ui/swing/util/UIUtil.java | Enhances resolution scaling methods and simplifies splash image sizing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a "Tip Of The Day" feature with internationalization support, including methods to retrieve today's tip and a random tip, along with rendering logic for word-wrapped tip text. In addition, UI scaling helpers in UIUtil.java have been updated to improve resolution and DPI scaling.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
megamek/src/megamek/common/util/TipOfTheDay.java | Implements the Tip Of The Day functionality, including tip selection and rendering. |
megamek/src/megamek/client/ui/swing/util/UIUtil.java | Adds new methods for monitor and resolution scaling and updates splash component logic. |
Co-authored-by: Copilot <[email protected]>
} catch (Exception e) { | ||
// When we get an exception, we've found all tips | ||
return count - 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has to be a better way to do this to get the number of tips.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see many other options:
a) or we store, in the file, also the number of tips in a dedicated key=value pair (making the i18n file store also numeric constants, that has to be kept updated while adding/removing tips)
b) or we ditch the key=value file format, and we use a dedicated file for specifically only the tips, one per line, and we use the lines count to know how many tips we have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you get the ResourceBundle
you're using, you would be able to get the list of its keys. From there you could filter it to keys that contain TipOfTheDay.tip
(maybe change it to be longer/more specific so there's no false positives?). This would also give the list of tips, and wouldn't require them to be numbered sequentially. Something like:
ResourceBundle bundle = I18n.getInstance().getResourceBundle(bundleName);
Enumeration<String> keys = bundle.getKeys();
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking making a resource file JUST for the tips for easier translation and just get the keys that way.
The ResourceBundle will handle I18N for us anyways and I plan to update the I18N class itself to be more dynamic in nature with ability to have defaults for the class as well as add in additional bundles as needed. A way to keep the resource files smaller and easier to manage for translations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok then, let's do a dedicated file without Key=Value pairs structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it!
In the future, I'd love to see an enhancement that lets values within the tip be dynamically replaced - like tip.7=You can press "{HOTKEY:VIEW_TOGGLE_ISOMETRIC}" to switch between top view and isometric view.
and then TipOfTheDayJava
would replace that with the actual hotkey before returning it to the player. That's for another day though,
I think this is a wonderful foundation for this feature and I'm excited to see this eventually get added to MegaMekLab and MekHQ as well.
The PR for MML is already up! |
add common Tip Of The Day implementation with i18n support.