Skip to content

Commit

Permalink
resolve #25,#26
Browse files Browse the repository at this point in the history
  • Loading branch information
Appbird committed Sep 4, 2021
1 parent 4b500b5 commit 666e8bb
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/ts/client/view/parts/RuleIndexPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const contents={
English: "If the scope of rule classes is duplicated and contradicts each other, the item at the top has priority."
}
}
type HandledType = {ruleInfo:RuleAttributeAndAppliedClassInfo, onClick:()=>void}
type HandledType = {ruleInfo:RuleAttributeAndAppliedClassInfo, onClick?:()=>void}
export class RuleIndexPart {
private rules:HandledType[] = []
constructor(
Expand All @@ -49,7 +49,7 @@ export class RuleIndexPart {
* ルールの目次のアイテムを追加します
* これで追加し終えた後に、refrectViewメソッドを実行する必要があります。
*/
appendNewRule(ruleInfo:RuleAttributeAndAppliedClassInfo, onClick:()=>void){
appendNewRule(ruleInfo:RuleAttributeAndAppliedClassInfo, onClick?:()=>void){
this.rules.push({ruleInfo,onClick})
}
refrectView(){
Expand All @@ -70,29 +70,33 @@ export class RuleIndexPart {
<div class="__item --top u-smallerChara">
<p class=""><i class=""></i> ${choiceString(contents.ruleName,this.language)}</p> <p class="">${choiceString(contents.ruleClass,this.language)}</p>
</div>
<hr noshade class="u-thin">
<hr noshade class="u-bold">
</div>
<div>
`);
const ruleIndexItemsSegment = findElementByClassNameWithErrorPossibility(ruleIndexSegment,"__list")
this.rules.forEach(({ruleInfo,onClick},index) => {
ruleIndexItemsSegment.appendChild(elementWithoutEscaping`
this.rules.forEach(({ruleInfo,onClick}) => {
const segment = ruleIndexItemsSegment.appendChild(elementWithoutEscaping`
<div class="__item">
<div>
<i class="${ruleInfo.rule.iconCSS}"></i> ${ruleInfo.rule.title}
${(ruleInfo.rule.note || 0) !== 0 ? ` <i class="u-redChara u-bolderChara">${choiceString(contents.annotated, this.language)}</i>` : ""}</div> <div class="__classItems">${this.generateClassDescriptionInRuleIndex(ruleInfo.appliedClass, this.language)}</div>
<i class="${ruleInfo.rule.iconCSS}"></i> ${ruleInfo.rule.title}
${(ruleInfo.rule.note || 0) !== 0 ? `<i class="u-redChara u-bolderChara">${choiceString(contents.annotated, this.language)}</i>` : ""}
</div>
<div class="__classItems">${this.generateClassDescriptionInRuleIndex(ruleInfo.appliedClass, this.language)}</div>
</div>
`).addEventListener(`click`, onClick)
if (index !== this.rules.length - 1)appendElement(ruleIndexItemsSegment,"hr","u-thin")
`)
if (onClick !== undefined) segment.addEventListener("click",onClick)
appendElement(ruleIndexItemsSegment,"hr","u-thin")
}
)
}
private generateClassDescriptionInRuleIndex(appliedClass: AppliedRuleClassResolved[], language: LanguageInApplication) {
return appliedClass.map(ruleClass => `
<div>
${this.generateCSSIcons(ruleClass)}
<div class="u-bolderChara u-inline">${ruleClass.title}</div>
<br>
<div class="u-bolderChara u-underline_text">
${this.generateCSSIcons(ruleClass)}
${ruleClass.title}
</div>
<div class="u-charaSpace_1em"></div>[${ruleClass.scope || choiceString(contents.noScope,language)}]`
+ `${(ruleClass.note?.length || 0) !== 0 ? ` <i class="u-redChara u-bolderChara">${choiceString(contents.annotated, language)}</i>` : ""}
</div>`
Expand Down
16 changes: 16 additions & 0 deletions src/ts/client/view/state/gameModeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ import {PageStateBaseClass} from "./Base/PageStateClass"
import { RuleIndexPart } from "../parts/RuleIndexPart";
import { MenuView } from "../parts/MenuView";
import { RuleAttributeAndAppliedClassInfo } from "../../../type/api/gameRule/RuleAttributeAndAppliedClassInfo";
import { TitleCupsuled } from "../parts/TitleCupsuled";
export const contents = {
title:{
Japanese: "ルール",
English: "Rule"
},
ruleIndex:{
Japanese: "目次",
English: "Index"
},
detail:{
Japanese: "詳細",
English: "Detail"
}
}
export class S_GameModeRule extends PageStateBaseClass<{gameSystemID:string,gameModeID:string},IAppUsedToReadAndChangeOnlyPageState>{
Expand All @@ -29,8 +38,15 @@ export class S_GameModeRule extends PageStateBaseClass<{gameSystemID:string,game
gameSystemEnv:this.requiredObj,
language: this.app.state.language
})).result

const ruleIndexTitlePart = new TitleCupsuled(appendElement(this.articleDOM,"div","u-marginUpDown2em"))
ruleIndexTitlePart.refresh(choiceString(contents.ruleIndex,this.app.state.language),undefined,{underline:true})

if (rules === undefined) throw new Error("rules === undefined")
const ruleIndexPart = new RuleIndexPart(appendElement(this.articleDOM,"div","u-marginUpDown2em"),this.app.state.language)

const ruleDetailTitlePart = new TitleCupsuled(appendElement(this.articleDOM,"div","u-marginUpDown2em"))
ruleDetailTitlePart.refresh(choiceString(contents.detail,this.app.state.language),undefined,{underline:true})
rules.sort(sort)
const ruleSegment = appendElement(this.articleDOM,"div","u-width90per")
for (const ruleObj of rules) {
Expand Down

0 comments on commit 666e8bb

Please sign in to comment.