This commit is contained in:
Riffaells 2024-12-04 17:56:18 +05:00
parent 5756955d92
commit dabd5841d7
6 changed files with 34 additions and 54 deletions

View File

@ -6,6 +6,6 @@
"description": "Allows you to easily display chessboards and play games in PGN format directly in your notes",
"author": "Riffaells",
"authorUrl": "https://gihub.com/Riffaells",
"fundingUrl": "https://gihub.com/Riffaells",
"fundingUrl": "",
"isDesktopOnly": false
}

View File

@ -2,6 +2,10 @@
export default {
'settings.title': 'ChessMate Settings',
'settings.boardColor': 'Board Color',
'settings.boardColorDesc': 'Choose the color for the chess board',
'settings.maxBoardSize': 'Max Board Size',
'settings.maxBoardSizeDesc': 'Set the maximum size of the chess board (in pixels)',
'settings.boardTheme': 'Board Theme',
'settings.boardThemeDesc': 'Choose the color theme for the chess board',
'settings.themeBrown': 'Brown',

View File

@ -1,4 +1,9 @@
// Russian
export default {
'settings.title': 'Настройки ChessMate',
'settings.boardColor': 'Цвет доски',
'settings.boardColorDesc': 'Выберите цвет для шахматной доски',
'settings.maxBoardSize': 'Максимальный размер доски',
'settings.maxBoardSizeDesc': 'Установите максимальный размер шахматной доски (в пикселях)',
};

View File

@ -25,7 +25,6 @@ export default class ChessMatePlugin extends Plugin {
pgn: options.pgn,
orientation: (options.orientation as 'white' | 'black') || 'white',
fen: options.fen || undefined,
// showMoves: options.showMoves === 'true' || this.settings.showMoves,
chessground: {
movable: {
free: true,
@ -42,16 +41,13 @@ export default class ChessMatePlugin extends Plugin {
red: { key: 'red', color: 'rgba(255,154,28,0.91)', opacity: 0.6 },
},
},
menu: {
}
menu: {},
};
PgnViewer(boardElement, viewerConfig);
boardElement.style.setProperty('--board-color', this.settings.accentColor);
container.style.setProperty('--max-board-size', `${this.settings.maxBoardSize}px`);
container.style.setProperty('--board-color', this.settings.boardColor);
});
}

View File

@ -3,19 +3,13 @@ import ChessMatePlugin from "./main";
import { t } from "./lang/helper";
export interface ChessMateSettings {
boardTheme: string;
pieceTheme: string;
showMoves: boolean;
accentColor: string;
boardSize: number;
boardColor: string;
maxBoardSize: number;
}
export const DEFAULT_SETTINGS: ChessMateSettings = {
boardTheme: 'brown',
pieceTheme: 'cburnett',
showMoves: true,
accentColor: "#ffeac3",
boardSize: 600
boardColor: '#f0d9b5',
maxBoardSize: 800
};
export class ChessMateSettingTab extends PluginSettingTab {
@ -33,49 +27,24 @@ export class ChessMateSettingTab extends PluginSettingTab {
containerEl.createEl('h2', { text: t('settings.title') });
new Setting(containerEl)
.setName(t('settings.boardTheme'))
.setDesc(t('settings.boardThemeDesc'))
.setName(t('settings.boardColor'))
.setDesc(t('settings.boardColorDesc'))
.addText(text => text
.setValue(this.plugin.settings.boardTheme)
.setValue(this.plugin.settings.boardColor)
.onChange(async (value) => {
this.plugin.settings.boardTheme = value;
this.plugin.settings.boardColor = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName(t('settings.pieceTheme'))
.setDesc(t('settings.pieceThemeDesc'))
.addDropdown(dropdown => dropdown
.addOptions({
cburnett: 'Cburnett',
alpha: 'Alpha',
classic: 'Classic'
})
.setValue(this.plugin.settings.pieceTheme)
.onChange(async (value) => {
this.plugin.settings.pieceTheme = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName(t('settings.showMoves'))
.setDesc(t('settings.showMovesDesc'))
.addToggle(toggle => toggle
.setValue(this.plugin.settings.showMoves)
.onChange(async (value) => {
this.plugin.settings.showMoves = value;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName(t('settings.boardSize'))
.setDesc(t('settings.boardSizeDesc'))
.setName(t('settings.maxBoardSize'))
.setDesc(t('settings.maxBoardSizeDesc'))
.addSlider(slider => slider
.setLimits(200, 800, 50)
.setValue(this.plugin.settings.boardSize)
.setValue(this.plugin.settings.maxBoardSize)
.setDynamicTooltip()
.onChange(async (value) => {
this.plugin.settings.boardSize = value;
this.plugin.settings.maxBoardSize = value;
await this.plugin.saveSettings();
}));
}

View File

@ -397,7 +397,12 @@ cg-board square.current-premove {
}
.lpv__board {
grid-area: board
grid-area: board;
width: 100%; /* Или установите фиксированное значение */
height: auto;
max-width: var(--max-board-size, 1200); /* Установите максимальную ширину */
max-height: var(--max-board-size, 900); /* Установите максимальную высоту */
}
.lpv__side {
@ -417,7 +422,8 @@ cg-board square.current-premove {
}
.lpv__controls {
grid-area: controls
grid-area: controls;
max-width: var(--max-board-size, 1200);
}
.lpv__menu, .lpv__pgn {
@ -447,7 +453,7 @@ cg-board square.current-premove {
/*}*/
.lpv__moves > index {
flex: 0 0 15%;
flex: 0 0 10%;
margin-right: 3%;
display: flex;
justify-content: flex-end