-
Notifications
You must be signed in to change notification settings - Fork 228
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
next: The custom theme allow to use external image, set font & color by config #378
Conversation
To be replaced by featurecat#378
To be replaced by featurecat#378
It is hard make random stone "white-stone-image" : "1.png,10.png" ? |
@ParmuzinAlexander |
@zsalch |
@OlivierBlanvillain |
Yes. My suggestion would be to always have custom theme on. Basically add a few options to the config JSON to change colors and the paths to the various images we use. |
Ok, I'll remove some redundant paths and use 'theme' instead of 'theme'+'custom-theme' in the config.txt file. |
@OlivierBlanvillain |
private String path = null; | ||
private JSONObject config = new JSONObject(); | ||
|
||
public Theme(String themeName) { |
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 would remove themeName
altogether, from this class and from the JSON config, it's never used for anything.
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.
Removed.
FileInputStream fp; | ||
try { | ||
fp = new FileInputStream(file); | ||
config = new JSONObject(new JSONTokener(fp)); |
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 think having a theme.txt
adds a lot of complexity in term for configuration for users. I would simply keep everything in the main config file. To have multiple themed Lizzie I would simply recommend having multiple config files with variations on the theme related configs.
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.
As conversation, keep two ways.
fp = new FileInputStream(file); | ||
config = new JSONObject(new JSONTokener(fp)); | ||
fp.close(); | ||
} catch (FileNotFoundException e) { |
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.
FileNotFoundException
extends IOException
, so you can remove that line.
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.
Removed.
@@ -137,6 +141,13 @@ public LizzieFrame() { | |||
JSONArray windowSize = Lizzie.config.uiConfig.getJSONArray("window-size"); | |||
setSize(windowSize.getInt(0), windowSize.getInt(1)); // use config file window size | |||
|
|||
// Allow change font in the config | |||
if (theme.fontName() != null) { | |||
systemDefaultFontName = theme.fontName(); |
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 think these name are obsolete if you start changing them. Instead I would use
fontName
regularFont
boldFont
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.
Rename to fontName, uiFontName, winrateFontName.
if (theme.fontName() != null) { | ||
systemDefaultFontName = theme.fontName(); | ||
OpenSansRegularBase = new Font(systemDefaultFontName, Font.PLAIN, 12); | ||
OpenSansSemiboldBase = new Font(systemDefaultFontName, Font.BOLD, 12); |
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.
Should the front size also be configurable? I it often the case than it needs adjustment depending on the font...
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.
Different areas have different font sizes. If need to configure them, you may need to add several different configurations.
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.
@featurecat @OlivierBlanvillain
Currently the font usage is now as follows:
OpenSansSemiboldBase: winrate text on the stone
OpenSansRegularBase: some UI text
systemDefaultFontName: some prompt text
And now the font size is basically responsive with the window, if you want to use the configuration file to change, I think we need to take some time to design the font usage.
So now only three font configurations are defined. The font size option only supports comment.
OpenSansSemiboldBase: winrate-font-name
OpenSansRegularBase: ui-font-name
systemDefaultFontName: font-name
blackStoneCached = | ||
ImageIO.read( | ||
new File( | ||
this.path |
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.
String p = this.path + /* File. */separator + config.optString("black-stone-image", "black.png");
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.
Fixed.
whiteStoneCached = | ||
ImageIO.read( | ||
new File( | ||
this.path |
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.
Same, just to make it fit in the 100 char limit...
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.
Fixed.
|
||
/** Use custom font */ | ||
public String fontName() { | ||
return config.optString("font-name", null); |
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.
Default to null
? Why not return the actual default font name?
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.
Change fontName logic.
public Color commentBackgroundColor() { | ||
JSONArray color = config.optJSONArray("comment-background-color"); | ||
if (color != null) { | ||
return new Color(color.getInt(0), color.getInt(1), color.getInt(2), color.getInt(3)); |
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.
Maybe we should give a nice error message in case somebody messes up the config file and color.length != 4
. Same comment for the methods below.
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.
Use new logic to process color.
@OlivierBlanvillain However, I also agree that you can set theme-related options directly in the config.txt file, so that users can modify them without enabling the theme. |
@featurecat @OlivierBlanvillain |
@zsalch Alright, if you think the split in I think we should turn both of these on by default for better discoverability. |
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.
LGTM!
…ustom theme)
Base on #365
Add a new way to customize the theme by external images, setup font & color of the comment.
The configuration method is as following:
1) Change the 'theme' value to specify your theme name:
"theme": "",
for example:
"theme": "mylike",
3) Create subfolders in the lizzie folder
/theme/
for example:
/theme/mylike
4) The custom-theme folder must include the config file 'theme.txt', the format as followings(use default when option not be specified):
{
"background-image" : "background.png",
"board-image" : "board.png",
"black-stone-image" : "black.png",
"white-stone-image" : "white.png",
"font-name": "Wawati SC",
"solid-stone-indicator": false,
"comment-background-color": [0, 0, 0, 200],
"comment-font-color": [255, 255, 255, 255],
"winrate-line-color": [0, 255, 0, 255],
"winrate-miss-line-color": [0, 0, 178, 255],
"blunder-bar-color": [255, 0, 0, 150]
}
e) Will use default theme when not found related config item.
f) Run the Lizzie.