Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | 22x 22x 22x 30x 9x 6x 5x 3x 22x 22x 7x 5x 5x 2x 7x 6x 6x 1x 2x 2x 2x 2x 2x 2x 32x 30x 32x 30x 30x 122x 108x 14x 14x 32x 32x 32x 32x | import { CommentSupplierConfigure, CommentSupplierConfigureImpl } from './commentSupplierConfigure' import { CommentSupplierConfigSupplier } from '../value/commentSupplierConfig' import { CommentContext } from '../model/commentContext' import { CommentSchema } from '../model/commentSupplier' /** * コメント生成器 ({@link CommentSupplier}) を簡便に作るためのクラス. * * CommentSupplier は本クラスを用いて作成してください. */ export class CommentSupplierBuilder extends CommentSupplierConfigureImpl { private static lastUsedScene?: g.Scene private static defaultConfig?: CommentSupplierConfigSupplier private static defaultConfigure?: CommentSupplierConfigure constructor (scene: g.Scene) { super(false, scene, new CommentSupplierConfigSupplier(CommentSupplierBuilder.getDefaultConfig(scene).get())) } /** * 作成する CommentSupplier に設定するコメント生成間隔(ミリ秒)を取得します. */ override interval (): number /** * 作成する CommentSupplier に設定するコメント生成間隔(ミリ秒)を設定します. * * @param interval コメントの生成間隔(ミリ秒) */ override interval (interval: number): CommentSupplierBuilder override interval (args?: number): number | CommentSupplierBuilder { if (typeof args === 'number') { super.interval(args) return this } return super.interval() } /** * 出力するコメントを追加します. * * @param comment コメント本文 * @param conditions コメントを出力する条件(複数指定可). 省略した場合、状況にかかわらず出力します. */ override addComment (comment: string, ...conditions: ((ctx: CommentContext) => boolean)[]): CommentSupplierBuilder { super.addComment(comment, ...conditions) return this } /** * 登録されたコメント設定を取得します */ override comments (): CommentSchema[] /** * 出力するコメントを設定します. * * これまで設定した情報は削除されます. * * @param comments コメント情報 */ override comments (comments: CommentSchema[]): CommentSupplierBuilder override comments (args?: CommentSchema[]): CommentSchema[] | CommentSupplierBuilder { if (args) { super.comments(args) return this } return super.comments() } /** * 作成する CommentSupplier のライブラリ利用者が自由に使えるフィールドを取得します. */ override vars (): unknown /** * 作成する CommentSupplier のライブラリ利用者が自由に使えるフィールドを設定します. * * @param vars ライブラリ利用者が自由に使えるフィールド */ override vars (vars: unknown): CommentSupplierBuilder override vars (args?: unknown): unknown | CommentSupplierBuilder { if (arguments.length > 0) { super.vars(args) return this } return super.vars() } /** * 各属性値に値を設定しなかった際に使用されるデフォルト値を設定します. * * @param scene 現在の scene を指定してください. */ static getDefault (scene: g.Scene): CommentSupplierConfigure { if (CommentSupplierBuilder.lastUsedScene !== scene) { CommentSupplierBuilder.resetDefault() } if (!CommentSupplierBuilder.defaultConfigure) { CommentSupplierBuilder.defaultConfigure = new CommentSupplierConfigureImpl(true, scene, CommentSupplierBuilder.getDefaultConfig(scene)) } CommentSupplierBuilder.lastUsedScene = scene return CommentSupplierBuilder.defaultConfigure } private static getDefaultConfig (scene: g.Scene): CommentSupplierConfigSupplier { if (CommentSupplierBuilder.lastUsedScene !== scene) { CommentSupplierBuilder.resetDefault() } if (!CommentSupplierBuilder.defaultConfig) { let isCommented = false CommentSupplierBuilder.defaultConfig = new CommentSupplierConfigSupplier({ interval: 1000, comments: [{ comment: 'わこつ', conditions: [() => { if (isCommented) { return false } else { isCommented = true return true } }] }], vars: undefined }) } CommentSupplierBuilder.lastUsedScene = scene return CommentSupplierBuilder.defaultConfig } /** * {@link getDefault} で設定した変更を消去します. * @internal */ private static resetDefault () { delete CommentSupplierBuilder.defaultConfig delete CommentSupplierBuilder.defaultConfigure } } |