-
Notifications
You must be signed in to change notification settings - Fork 333
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
tip of the day #6841
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6841 +/- ##
==========================================
Coverage 30.69% 30.69%
- Complexity 16793 16816 +23
==========================================
Files 2935 2936 +1
Lines 285360 285485 +125
Branches 49629 49642 +13
==========================================
+ Hits 87587 87627 +40
- Misses 191486 191566 +80
- Partials 6287 6292 +5 ☔ 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 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! |
@pavelbraginskiy Have you're requests been met. |
/* | ||
* Copyright (c) 2025 - The MegaMek Team. All Rights Reserved. | ||
* | ||
* This file is part of MegaMek. | ||
* | ||
* MegaMek is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MegaMek is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with MegaMek. If not, see <http://www.gnu.org/licenses/>. | ||
*/ |
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.
This still isn't the correct new copyright notice.
add common Tip Of The Day implementation with i18n support.