|
6 | 6 | import { getEasingArgDefault, hasArgs } from '../util/easing'
|
7 | 7 | import { Valuable } from '../util/stores'
|
8 | 8 | import { isCurrentFormat } from '../blueprintFormat'
|
| 9 | + import { createPropertySubscribable } from '../util/moddingTools' |
| 10 | + import { Subscribable } from '../util/subscribable' |
9 | 11 |
|
10 | 12 | const ICONS = Object.fromEntries(
|
11 | 13 | (ICON_IMPORTS as unknown as any[]).map((icon, i) => [
|
|
102 | 104 | }
|
103 | 105 |
|
104 | 106 | events.SELECT_KEYFRAME.subscribe((keyframe?: _Keyframe) => {
|
| 107 | + console.log('selected keyframe', keyframe) |
105 | 108 | if (
|
106 | 109 | isCurrentFormat() &&
|
107 | 110 | keyframe &&
|
|
130 | 133 | </script>
|
131 | 134 |
|
132 | 135 | {#if selectedKeyframe}
|
133 |
| - <div class="bar flex"> |
134 |
| - <label |
135 |
| - for="easing_type_input" |
136 |
| - class="undefined" |
137 |
| - style="font-weight: unset; width: 100px; text-align: left;" |
138 |
| - title={translate('panel.keyframe.easing_type.description')} |
139 |
| - > |
140 |
| - {translate('panel.keyframe.easing_type.title')} |
141 |
| - </label> |
142 |
| - {#key easingType} |
143 |
| - <div id="easing_type_input" class="easing-container"> |
144 |
| - {#each easingTypes as ease} |
145 |
| - <button |
146 |
| - class="easing-type" |
147 |
| - title={translate(`panel.keyframe.easing_type.options.${ease}`)} |
148 |
| - on:click={() => setSelectedEasing(ease, easingMode)} |
149 |
| - > |
150 |
| - <img |
151 |
| - class={easingType === ease ? 'selected-keyframe-icon' : ''} |
152 |
| - src={ICONS[ease]} |
153 |
| - alt={ease} |
154 |
| - /> |
155 |
| - </button> |
156 |
| - {/each} |
157 |
| - </div> |
158 |
| - {/key} |
159 |
| - </div> |
160 |
| - {#if selectedKeyframe.easing !== 'linear'} |
| 136 | + {#if selectedKeyframe?.interpolation === 'linear'} |
161 | 137 | <div class="bar flex">
|
162 | 138 | <label
|
163 |
| - for="easing_mode_input" |
| 139 | + for="easing_type_input" |
164 | 140 | class="undefined"
|
165 | 141 | style="font-weight: unset; width: 100px; text-align: left;"
|
166 |
| - title={translate('panel.keyframe.easing_mode.description')} |
| 142 | + title={translate('panel.keyframe.easing_type.description')} |
167 | 143 | >
|
168 |
| - {translate('panel.keyframe.easing_mode.title')} |
| 144 | + {translate('panel.keyframe.easing_type.title')} |
169 | 145 | </label>
|
170 |
| - {#key easingMode} |
171 |
| - <div id="easing_mode_input" class="easing-container"> |
172 |
| - {#each easingModes as mode} |
| 146 | + {#key easingType} |
| 147 | + <div id="easing_type_input" class="easing-container"> |
| 148 | + {#each easingTypes as ease} |
173 | 149 | <button
|
174 | 150 | class="easing-type"
|
175 |
| - title={translate(`panel.keyframe.easing_mode.options.${mode}`)} |
176 |
| - on:click={() => setSelectedEasing(easingType, mode)} |
| 151 | + title={translate(`panel.keyframe.easing_type.options.${ease}`)} |
| 152 | + on:click={() => setSelectedEasing(ease, easingMode)} |
177 | 153 | >
|
178 | 154 | <img
|
179 |
| - class={easingMode === mode ? 'selected-keyframe-icon' : ''} |
180 |
| - src={EASING_MODE_ICONS[mode]} |
181 |
| - alt={mode} |
| 155 | + class={easingType === ease ? 'selected-keyframe-icon' : ''} |
| 156 | + src={ICONS[ease]} |
| 157 | + alt={ease} |
182 | 158 | />
|
183 | 159 | </button>
|
184 | 160 | {/each}
|
185 | 161 | </div>
|
186 | 162 | {/key}
|
187 | 163 | </div>
|
188 |
| - {/if} |
189 |
| - {#if hasArgs(selectedKeyframe?.easing)} |
190 |
| - <div class="bar flex"> |
191 |
| - <label |
192 |
| - for="easing_arg_input" |
193 |
| - class="undefined" |
194 |
| - style="font-weight: unset; width: 100px; text-align: left;" |
195 |
| - title={translate(`panel.keyframe.easing_args.easing_arg.${easingType}.description`)} |
196 |
| - > |
197 |
| - {translate(`panel.keyframe.easing_args.easing_arg.${easingType}.title`)} |
198 |
| - </label> |
199 |
| - <input |
200 |
| - id="easing_arg_input" |
201 |
| - class="dark_bordered tab_target" |
202 |
| - style="width: 66px; margin-left: 2px;" |
203 |
| - type="number" |
204 |
| - step="0.1" |
205 |
| - min="0" |
206 |
| - bind:value={$easingArg} |
207 |
| - /> |
| 164 | + {#if selectedKeyframe.easing !== 'linear'} |
| 165 | + <div class="bar flex"> |
| 166 | + <label |
| 167 | + for="easing_mode_input" |
| 168 | + class="undefined" |
| 169 | + style="font-weight: unset; width: 100px; text-align: left;" |
| 170 | + title={translate('panel.keyframe.easing_mode.description')} |
| 171 | + > |
| 172 | + {translate('panel.keyframe.easing_mode.title')} |
| 173 | + </label> |
| 174 | + {#key easingMode} |
| 175 | + <div id="easing_mode_input" class="easing-container"> |
| 176 | + {#each easingModes as mode} |
| 177 | + <button |
| 178 | + class="easing-type" |
| 179 | + title={translate(`panel.keyframe.easing_mode.options.${mode}`)} |
| 180 | + on:click={() => setSelectedEasing(easingType, mode)} |
| 181 | + > |
| 182 | + <img |
| 183 | + class={easingMode === mode ? 'selected-keyframe-icon' : ''} |
| 184 | + src={EASING_MODE_ICONS[mode]} |
| 185 | + alt={mode} |
| 186 | + /> |
| 187 | + </button> |
| 188 | + {/each} |
| 189 | + </div> |
| 190 | + {/key} |
| 191 | + </div> |
| 192 | + {/if} |
| 193 | + {#if hasArgs(selectedKeyframe?.easing)} |
| 194 | + <div class="bar flex"> |
| 195 | + <label |
| 196 | + for="easing_arg_input" |
| 197 | + class="undefined" |
| 198 | + style="font-weight: unset; width: 100px; text-align: left;" |
| 199 | + title={translate( |
| 200 | + `panel.keyframe.easing_args.easing_arg.${easingType}.description`, |
| 201 | + )} |
| 202 | + > |
| 203 | + {translate(`panel.keyframe.easing_args.easing_arg.${easingType}.title`)} |
| 204 | + </label> |
| 205 | + <input |
| 206 | + id="easing_arg_input" |
| 207 | + class="dark_bordered tab_target" |
| 208 | + style="width: 66px; margin-left: 2px;" |
| 209 | + type="number" |
| 210 | + step="0.1" |
| 211 | + min="0" |
| 212 | + bind:value={$easingArg} |
| 213 | + /> |
| 214 | + </div> |
| 215 | + {/if} |
| 216 | + {:else} |
| 217 | + <div class="easings-disabled"> |
| 218 | + {translate('panel.keyframe.nonlinear_interpolation')} |
208 | 219 | </div>
|
209 | 220 | {/if}
|
210 | 221 | {/if}
|
211 | 222 |
|
212 | 223 | <style>
|
| 224 | + .easings-disabled { |
| 225 | + margin-left: 16px; |
| 226 | + font-size: 16px; |
| 227 | + color: var(--color-subtle_text); |
| 228 | + text-wrap: balance; |
| 229 | + margin-bottom: 1rem; |
| 230 | + font-style: italic; |
| 231 | + } |
| 232 | +
|
213 | 233 | .easing-container {
|
214 | 234 | display: flex;
|
215 | 235 | flex-direction: row;
|
|
0 commit comments