MCPcopy
hub / github.com/feichao93/battle-city / render

Method render

app/components/ChooseStageScene.tsx:74–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72 }
73
74 render() {
75 const { match, dispatch, stages } = this.props
76 const stageNames = stages.map(s => s.name)
77 const { stageName } = match.params
78 if (!stageNames.includes(stageName)) {
79 return <Redirect to={`${match.url}/${stageNames.first()}`} />
80 }
81 const index = stageNames.indexOf(stageName)
82 return (
83 <Screen background="#333">
84 <Text content="choose stage:" x={0.5 * B} y={0.5 * B} />
85 <StagePreview
86 key={index - 1}
87 stage={index === 0 ? null : stages.get(index - 1)}
88 x={0.75 * B}
89 y={4.375 * B}
90 scale={1 / 4}
91 />
92 <StagePreview
93 key={index}
94 stage={stages.get(index)}
95 x={4.75 * B}
96 y={2.75 * B}
97 scale={1 / 2}
98 />
99 <StagePreview
100 key={index + 1}
101 stage={stages.get(index + 1)}
102 x={12 * B}
103 y={4.375 * B}
104 scale={1 / 4}
105 />
106 <Text content={`stage ${stageName}`} x={6.5 * B} y={9.75 * B} />
107 <g className="button-areas" transform={`translate(${2.5 * B}, ${12 * B})`}>
108 <TextButton
109 content="prev"
110 disabled={index === 0}
111 x={0}
112 y={0}
113 onClick={this.onChoosePrevStage}
114 />
115 <TextButton
116 content="next"
117 disabled={index === stageNames.size - 1}
118 x={3 * B}
119 y={0}
120 onClick={this.onChooseNextStage}
121 />
122 <TextButton content="play" stroke="#96d332" x={6 * B} y={0} onClick={this.onStartPlay} />
123 <TextButton content="back" x={9 * B} y={0} onClick={() => dispatch(replace('/'))} />
124 </g>
125 <g className="hint" transform={`translate(${0.5 * B},${14.5 * B}) scale(0.5)`}>
126 <Text fill="#999" content="Press left or right to choose stages. Press fire to start." />
127 </g>
128 </Screen>
129 )
130 }
131}

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected