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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 8x 13x 4x 4x 9x 10x 2x 2x 8x 15x 5x 4x 10x 10x 2x 2x 8x 10x 2x 2x 8x 11x 3x 3x 8x 10x 2x 2x 8x 15x 5x 4x 10x 17x 6x 4x 11x 15x 5x 4x 10x 17x 6x 4x 11x 7x 7x 7x 7x 7x 7x 15x 10x 15x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 15x 15x 17x 17x | import { LiveOnAirSceneConfigSupplierOptions, LiveOnAirSceneConfigure, LiveOnAirSceneConfigureImpl } from './liveOnAirSceneConfigure' import { image } from '../util/loader' import { BroadcasterConfig, BroadcasterConfigSupplier } from '../value/broadcasterConfig' import { LayerConfig, LayerConfigSupplier } from '../value/layerConfig' import { SpotConfig, SpotConfigSupplier } from '../value/spotConfig' import { FieldConfig, FieldConfigSupplier } from '../value/fieldConfig' import { ScreenConfig, ScreenConfigSupplier } from '../value/screenConfig' import { SampleLive } from '../model/live' import { CommentSupplierConfig, CommentSupplierConfigSupplier } from '../value/commentSupplierConfig' import { CommentDeployerConfig, CommentDeployerConfigSupplier } from '../value/commentDeployerConfig' import { ScorerConfig, ScorerConfigSupplier } from '../value/scorerConfig' import { TickerConfig, TickerConfigSupplier } from '../value/tickerConfig' import { CommentContextConfig, CommentContextConfigSupplier } from '../value/commentContextConfig' import { LiveContextConfig, LiveContextConfigSupplier } from '../value/liveContextConfig' /** * ゲームが動作する g.Scene を簡便に作るためのクラス. */ export class LiveOnAirSceneBuilder extends LiveOnAirSceneConfigureImpl { private static lastUsedScene?: g.Scene private static defaultConfig?: Omit<LiveOnAirSceneConfigSupplierOptions, 'isDefault'> private static defaultConfigure?: LiveOnAirSceneConfigure constructor (game: g.Game) { super({ isDefault: false, ...LiveOnAirSceneBuilder.getDefaultConfig(game) }) } /** * g.Scene 上に配置される各レイヤーの領域値を設定します. * * @param config 設定されている各レイヤーについての領域の位置・大きさ */ override layer (config: Partial<LayerConfig>): LiveOnAirSceneBuilder /** * g.Scene 上に配置される各レイヤーの領域値を取得します. * */ override layer (): Readonly<LayerConfig> override layer (args?: Partial<LayerConfig>): LiveOnAirSceneBuilder | Readonly<LayerConfig> { if (args) { super.layer(args) return this } return super.layer() } /** * マップ ({@link Field}) の属性情報を設定します. * * @param config Field の設定値 */ override field (config: Partial<FieldConfig>): LiveOnAirSceneBuilder /** * マップ ({@link Field}) の属性情報を取得します. */ override field (): Readonly<FieldConfig> override field (args?: Partial<FieldConfig>): LiveOnAirSceneBuilder | Readonly<FieldConfig> { if (args) { super.field(args) return this } return super.field() } /** * 作成する {@link Broadcaster} の属性情報を設定します. * * @param config Broadcaster の設定値 */ override broadcaster (config: Partial<BroadcasterConfig>): LiveOnAirSceneBuilder /** * 作成する {@link Broadcaster} の属性情報を取得します. */ override broadcaster (): Readonly<BroadcasterConfig> override broadcaster (args?: Partial<BroadcasterConfig>): LiveOnAirSceneBuilder | Readonly<BroadcasterConfig> { if (args) { super.broadcaster(args) return this } return super.broadcaster() } /** * 生放送の画面 ({@link Screen}) の属性情報を設定します. * * @param config Field の設定値 */ override screen (config: Partial<ScreenConfig>): LiveOnAirSceneBuilder /** * 生放送の画面 ({@link Screen}) の属性情報を取得します. */ override screen (): Readonly<ScreenConfig> override screen (args?: Partial<ScreenConfig>): LiveOnAirSceneBuilder | Readonly<ScreenConfig> { if (args) { super.screen(args) return this } return super.screen() } /** * {@link LiveContext} の初期値を取得します. */ override liveContext (): Readonly<LiveContextConfig> /** * {@link LiveContext} の初期値を設定します. * * @param config LiveContext の初期値 */ override liveContext (config: Partial<LiveContextConfig>): LiveOnAirSceneBuilder override liveContext (args?: Partial<LiveContextConfig>): LiveOnAirSceneBuilder | Readonly<LiveContextConfig> { if (args) { super.liveContext(args) return this } return super.liveContext() } /** * 作成する {@link Spot} の属性情報を設定します. * * @param config Spot の設定値 */ override spot (config: Partial<SpotConfig>): LiveOnAirSceneBuilder /** * 作成する {@link Spot} の属性情報を取得します. */ override spot (): readonly SpotConfig[] override spot (args?: Partial<SpotConfig>): LiveOnAirSceneBuilder | readonly SpotConfig[] { if (args) { super.spot(args) return this } return super.spot() } /** * 作成する {@link CommentContext} の属性情報を設定します. * * @param config CommentContext の設定値 */ override commentContext (config: Partial<CommentContextConfig>): LiveOnAirSceneBuilder /** * 作成する {@link CommentContext} の属性情報を取得します. */ override commentContext (): Readonly<CommentContextConfig> override commentContext (args?: Partial<CommentContextConfig>): LiveOnAirSceneBuilder | Readonly<CommentContextConfig> { if (args) { super.commentContext(args) return this } return super.commentContext() } /** * 作成する {@link CommentSupplier} の属性情報を設定します. * * @param config CommentSupplier の設定値 */ override commentSupplier (config: Partial<CommentSupplierConfig>): LiveOnAirSceneBuilder /** * 作成する {@link CommentSupplier} の属性情報を取得します. */ override commentSupplier (): Readonly<CommentSupplierConfig> override commentSupplier (args?: Partial<CommentSupplierConfig>): LiveOnAirSceneBuilder | Readonly<CommentSupplierConfig> { if (args) { super.commentSupplier(args) return this } return super.commentSupplier() } /** * 作成する {@link CommentSupplier} の属性情報を設定します. * * @param config CommentSupplier の設定値 */ override commentDeployer (config: Partial<CommentDeployerConfig>): LiveOnAirSceneBuilder /** * 作成する {@link CommentSupplier} の属性情報を取得します. */ override commentDeployer (): Readonly<CommentDeployerConfig> override commentDeployer (args?: Partial<CommentDeployerConfig>): LiveOnAirSceneBuilder | Readonly<CommentDeployerConfig> { if (args) { super.commentDeployer(args) return this } return super.commentDeployer() } /** * 作成する {@link Scorer} の属性情報を設定します. * @param config Scorer の設定値 */ override scorer (config: Partial<ScorerConfig>): LiveOnAirSceneBuilder /** * 作成する{@link Scorer} の属性情報を取得します. */ override scorer (): Readonly<ScorerConfig> override scorer (args?: Partial<ScorerConfig>): LiveOnAirSceneBuilder | Readonly<ScorerConfig> { if (args) { super.scorer(args) return this } return super.scorer() } /** * 作成する {@link Ticker} の属性情報を設定します. * @param config Ticker の設定値 */ override ticker (config: Partial<TickerConfig>): LiveOnAirSceneBuilder /** * 作成する{@link Ticker} の属性情報を取得します. */ override ticker (): Readonly<TickerConfig> override ticker (args?: Partial<TickerConfig>): LiveOnAirSceneBuilder | Readonly<TickerConfig> { if (args) { super.ticker(args) return this } return super.ticker() } /** * 各属性値に値を設定しなかった際に使用されるデフォルト値を設定します. * * @param game g.game を指定してください. */ static getDefault (game: g.Game): LiveOnAirSceneConfigure { if (LiveOnAirSceneBuilder.lastUsedScene !== game.scene()) { LiveOnAirSceneBuilder.resetDefault() } if (!LiveOnAirSceneBuilder.defaultConfigure) { LiveOnAirSceneBuilder.defaultConfigure = new LiveOnAirSceneConfigureImpl({ isDefault: true, ...LiveOnAirSceneBuilder.getDefaultConfig(game) }) } this.lastUsedScene = game.scene() return LiveOnAirSceneBuilder.defaultConfigure } private static getDefaultConfig (game: g.Game): Omit<LiveOnAirSceneConfigSupplierOptions, 'isDefault'> { if (LiveOnAirSceneBuilder.lastUsedScene !== game.scene()) { LiveOnAirSceneBuilder.resetDefault() } if (!LiveOnAirSceneBuilder.defaultConfig) { const layer = new LayerConfigSupplier({ field: { x: 100, y: 100, width: game.width - 200, height: game.height - 200 }, screen: { x: 100, y: 100, width: game.width - 200, height: game.height - 200 }, comment: { x: 100, y: 100, width: game.width - 200, height: game.height - 200 }, header: { x: 0, y: 0, width: game.width, height: 100 }, vars: undefined }) const field = new FieldConfigSupplier({ vars: undefined }) const broadcaster = new BroadcasterConfigSupplier({ x: 0, y: 0, speed: 1, asset: image(game, 'image/broadcaster.default.png'), vars: undefined }) const screen = new ScreenConfigSupplier({ vars: undefined }) const liveContext = new LiveContextConfigSupplier({ vars: undefined }) const spot = new SpotConfigSupplier({ x: 0, y: 0, locked: image(game.scene()!, 'image/spot.default.locked.png'), unvisited: image(game.scene()!, 'image/spot.default.unvisited.png'), disabled: image(game.scene()!, 'image/spot.default.disabled.png'), normal: image(game.scene()!, 'image/spot.default.normal.png'), name: '', labelFont: new g.DynamicFont({ game, fontFamily: 'sans-serif', size: 25, fontColor: 'black', strokeColor: 'white', strokeWidth: 3 }), liveClass: SampleLive, vars: undefined }) const commentContext = new CommentContextConfigSupplier({ vars: undefined }) const commentSupplier = new CommentSupplierConfigSupplier({ interval: 1000, comments: [], // ここにいれると CommentSupplierBuilder が更にデフォルト値を足してしまう vars: undefined }) const commentDeployer = new CommentDeployerConfigSupplier({ speed: 4, intervalY: 40, font: new g.DynamicFont({ game, fontFamily: 'sans-serif', size: 35, strokeColor: 'white', strokeWidth: 4 }), vars: undefined }) const scorer = new ScorerConfigSupplier({ font: new g.DynamicFont({ game, fontFamily: 'monospace', size: 40, strokeColor: 'white', strokeWidth: 4 }), digit: 4, prefix: 'スコア', suffix: '点', refrainsSendingScore: false, vars: undefined }) const ticker = new TickerConfigSupplier({ frame: 1800, font: new g.DynamicFont({ game, fontFamily: 'monospace', size: 40, strokeColor: 'white', strokeWidth: 4 }), digit: 2, prefix: '残り', suffix: '秒', vars: undefined }) LiveOnAirSceneBuilder.defaultConfig = { game, layer, field, broadcaster, screen, liveContext, spot, commentContext, commentSupplier, commentDeployer, scorer, ticker } } this.lastUsedScene = game.scene() return LiveOnAirSceneBuilder.defaultConfig } /** * {@link getDefault} で設定した変更を消去します. * @internal */ private static resetDefault () { delete LiveOnAirSceneBuilder.defaultConfig delete LiveOnAirSceneBuilder.defaultConfigure } } |