2023-10-15 06:07:10 +00:00
import { _ as s , c as a , o as n , a as e } from "./app.0f100cc5.js" ; const u = JSON . parse ( '{"title":"Grids","description":"","frontmatter":{},"headers":[],"relativePath":"public/kronos/docs/grids.md","lastUpdated":null}' ) , l = { name : "public/kronos/docs/grids.md" } , o = e ( ` <h1 id="grids" tabindex="-1">Grids <a class="header-anchor" href="#grids" aria-hidden="true">#</a></h1><p>Grids are an easier way of making a group of similar clickables. They all have the same behavior, but are different based on their data.</p><p><strong>NOTE: Gridables are similar to clickables in some respects, but are fundamentally different from normal TMT components in quite a few ways. Be sure to keep these in mind:</strong></p><ul><li>Gridable ids use base 100 instead of base 10, so you can have more than 10 tiles in a row. This means that a grid might look like this: 101 102 201 202</li><li>Individual gridables are not defined individually. All properties go directly into the "grid" object. Functions are called with arguments for the id of the gridables and its associated data, so you can give them the appropriate appearance and properties based on that.</li><li>If you need two unrelated grids in a layer, you'll need to use a layer proxy component.</li></ul><p>Useful functions for dealing with grids:</p><ul><li>getGridData(layer, id): get the data for the chosen gridable</li><li>setGridData(layer, id, state): set the data for the chosen gridable</li><li>gridEffect(layer, id): get the effect for the chosen gridable</li></ul><p>The grid should be formatted like this:</p><div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki"><code><span class="line"><span style="color:#FFCB6B;">grid</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
2022-10-05 00:48:27 +00:00
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F F C B 6 B ; " > r o w s < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > : < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 4 < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 6 7 6 E 9 5 ; " > / / I f t h e s e a r e d y n a m i c m a k e s u r e t o h a v e a m a x v a l u e a s w e l l ! < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F F C B 6 B ; " > c o l s < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > : < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 5 < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g e t S t a r t D a t a < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 0 < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g e t U n l o c k e d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 6 7 6 E 9 5 ; " > / / D e f a u l t < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F F 9 C A C ; " > t r u e < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g e t C a n C l i c k < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > d a t a < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F F 9 C A C ; " > t r u e < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > o n C l i c k < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > d a t a < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > [ < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ] < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > g r i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > [ < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ] < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > + + < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g e t D i s p l a y < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > d a t a < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > d a t a < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > e t c < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#89DDFF;" > } < / s p a n > < / s p a n >
< span class = "line" > < / s p a n > < / c o d e > < / p r e > < / d i v > < p > F e a t u r e s : < / p > < u l > < l i > < p > r o w s , c o l s : T h e a m o u n t o f r o w s a n d c o l u m n s o f g r i d a b l e t o d i s p l a y . < / p > < / l i > < l i > < p > m a x R o w s , m a x C o l s : < s t r o n g > s o m e t i m e s n e e d e d < / s t r o n g > . I f r o w s o r c o l s a r e d y n a m i c , y o u n e e d t o d e f i n e t h e m a x i m u m a m o u n t t h a t t h e r e c a n b e ( y o u c a n i n c r e a s e i t w h e n y o u u p d a t e t h e g a m e t h o u g h ) . T h e s e C A N N O T b e d y n a m i c . < / p > < / l i > < l i > < p > g e t S t a r t D a t a ( i d ) : C r e a t e s t h e d e f a u l t d a t a f o r t h e g r i d a b l e a t t h i s p o s i t i o n . T h i s c a n b e a n o b j e c t , o r a r e g u l a r v a l u e . < / p > < / l i > < l i > < p > g e t U n l o c k e d ( i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . R e t u r n s t r u e i f t h e g r i d a b l e a t t h i s p o s i t i o n s h o u l d b e v i s i b l e . < / p > < / l i > < l i > < p > g e t T i t l e ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . R e t u r n s t e x t t h a t s h o u l d d i s p l a y e d a t t h e t o p i n a l a r g e r f o n t , b a s e d o n t h e p o s i t i o n a n d d a t a o f t h e g r i d a b l e . < / p > < / l i > < l i > < p > g e t D i s p l a y ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . R e t u r n s e v e r y t h i n g t h a t s h o u l d b e d i s p l a y e d o n t h e g r i d a b l e a f t e r t h e t i t l e , b a s e d o n t h e p o s i t i o n a n d d a t a o f t h e g r i d a b l e . < / p > < / l i > < l i > < p > g e t S t y l e ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . R e t u r n s C S S t o a p p l y t o t h i s g r i d a b l e , i n t h e f o r m o f a n o b j e c t w h e r e t h e k e y s a r e C S S a t t r i b u t e s , a n d t h e v a l u e s a r e t h e v a l u e s f o r t h o s e a t t r i b u t e s ( b o t h a s s t r i n g s ) . < / p > < / l i > < l i > < p > g e t C a n C l i c k ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . A f u n c t i o n r e t u r n i n g a b o o l t o d e t e r m i n e i f y o u c a n c l i c k a g r i d a b l e , b a s e d o n i t s d a t a a n d p o s i t i o n . I f a b s e n t , y o u c a n a l w a y s c l i c k i t . < / p > < / l i > < l i > < p > o n C l i c k ( d a t a , i d ) : A f u n c t i o n t h a t i m p l e m e n t s c l i c k i n g o n t h e g r i d a b l e , b a s e d o n i t s p o s i t i o n a n d d a t a . < / p > < / l i > < l i > < p > o n H o l d ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > A f u n c t i o n t h a t i s c a l l e d 2 0 x / s e c w h e n t h e b u t t o n i s h e l d f o r a t l e a s t 0 . 2 5 s e c o n d s . < / p > < / l i > < l i > < p > g e t E f f e c t ( d a t a , i d ) : < s t r o n g > o p t i o n a l < / s t r o n g > . A f u n c t i o n t h a t c a l c u l a t e s a n d r e t u r n s a g r i d a b l e & # 3 9 ; s e f f e c t , b a s e d o n i t s p o s i t i o n a n d d a t a . ( W h a t e v e r t h a t m e a n s f o r a g r i d a b l e ) < / p > < / l i > < l i > < p > l a y e r : < s t r o n g > a s s i g n e d a u t o m a g i c a l l y < / s t r o n g > . I t & # 3 9 ; s t h e s a m e v a l u e a s t h e n a m e o f t h i s l a y e r , s o y o u c a n d o < c o d e > p l a y e r [ t h i s . l a y e r ] . p o i n t s < / c o d e > o r s i m i l a r . < / p > < / l i > < / u l > ` , 1 0 ) , t = [ o ] ; f u n c t i o n p ( r , i , c , d , y , F ) { r e t u r n n ( ) , a ( " d i v " , n u l l , t ) } c o n s t g = s ( l , [ [ " r e n d e r " , p ] ] ) ; e x p o r t { u a s _ _ p a g e D a t a , g a s d e f a u l t } ;