Skip to content

Commit 1afd00f

Browse files
committed
feat: game grid item
1 parent 8da6e6e commit 1afd00f

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

electron/renderer/types/game.types.ts

+54
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export interface GameLogLine {
1919
eventId: string;
2020
/**
2121
* The game stream id that this line is destined for.
22+
* Example: 'percWindow' for spells.
2223
*/
2324
streamId: string;
2425
/**
@@ -30,3 +31,56 @@ export interface GameLogLine {
3031
*/
3132
text: string;
3233
}
34+
35+
/**
36+
* When the game socket sends data, it may be tagged with a stream id.
37+
* The stream id indicates which game "window" the data is intended for.
38+
*
39+
* An item id is the unique identifier we use in Phoenix for the same
40+
* logical concept, but allows us to use more consistent or descriptive
41+
* values. Or in the case of the main stream, to use a non-blank value!
42+
*
43+
* Users will be allowed to create new streams to customize how
44+
* game content is routed to the UI. Sometimes custom scripts output
45+
* to specific streams, or DragonRealms introduces new streams before
46+
* we update the code to support them.
47+
*/
48+
export interface GameItemInfo {
49+
/**
50+
* Unique identifier for the game stream.
51+
* Assigned by DragonRealms.
52+
* Example: 'percWindow' for spells.
53+
*/
54+
streamId: string;
55+
/**
56+
* Our logical id for the game stream item.
57+
* Generally matches the stream id, but more consistent.
58+
*/
59+
itemId: GameItemId | string;
60+
/**
61+
* User-friendly title for the game stream.
62+
* Example: 'Spells' or 'Main'.
63+
*/
64+
itemTitle: string;
65+
}
66+
67+
export enum GameItemId {
68+
MAIN = 'main',
69+
EXPERIENCE = 'experience',
70+
ROOM = 'room',
71+
SPELLS = 'spells',
72+
INVENTORY = 'inventory',
73+
FAMILIAR = 'familiar',
74+
THOUGHTS = 'thoughts',
75+
COMBAT = 'combat',
76+
ASSESS = 'assess',
77+
ARRIVALS = 'arrivals',
78+
DEATHS = 'deaths',
79+
ATMOSPHERICS = 'atmospherics',
80+
CHATTER = 'chatter',
81+
CONVERSATION = 'conversation',
82+
WHISPERS = 'whispers',
83+
TALK = 'talk',
84+
OOC = 'ooc',
85+
GROUP = 'group',
86+
}

electron/renderer/types/grid.types.ts

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import type { ReactNode } from 'react';
2+
import type { GameItemInfo } from './game.types.js';
3+
4+
export interface GridItemContent extends GridItemInfo {
5+
/**
6+
* The content to display in the grid item.
7+
*/
8+
content: ReactNode;
9+
}
10+
11+
/**
12+
* The information shared between the grid item and the grid.
13+
* For example, to notify when the item's layout or position changes.
14+
*/
15+
export interface GridItemInfo {
16+
itemId: string;
17+
itemTitle: string;
18+
isFocused: boolean;
19+
layout: GridItemLayout;
20+
}
21+
22+
export interface GridItemConfig {
23+
/**
24+
* Info about the game stream that this grid item is for.
25+
*/
26+
gameItemInfo: GameItemInfo;
27+
/**
28+
* When this item is visible (i.e. added to the grid layout)
29+
* then these are the grid item ids where to stream this item's content.
30+
* Usually, this is the item's own id.
31+
*/
32+
whenVisibleStreamToItemIds: Array<string>;
33+
/**
34+
* When this item is hidden (i.e. removed from the grid layout)
35+
* then these are the grid item ids where to stream this item's content.
36+
* Usually, the fallback is the main grid item or empty array.
37+
*/
38+
whenHiddenStreamToItemIds: Array<string>;
39+
}
40+
41+
/**
42+
* The dimension for the grid where the item may be dragged and resized.
43+
*/
44+
export interface GridItemBoundary {
45+
/**
46+
* The max height of the grid in pixels.
47+
*/
48+
height: number;
49+
/**
50+
* The max width of the grid in pixels.
51+
*/
52+
width: number;
53+
}
54+
55+
/**
56+
* The positional layout for the grid item.
57+
*/
58+
export interface GridItemLayout {
59+
/**
60+
* The x coordinate for the grid item.
61+
* The leftmost edge of the grid item.
62+
*/
63+
x: number;
64+
/**
65+
* The y coordinate for the grid item.
66+
* The topmost edge of the grid item.
67+
*/
68+
y: number;
69+
/**
70+
* The width dimension for the grid item.
71+
* The horizontal length of the grid item.
72+
* Rightmost edge is `x + width`.
73+
*/
74+
width: number;
75+
/**
76+
* The height dimension for the grid item.
77+
* The vertical length of the grid item.
78+
* Bottommost edge is `y + height`.
79+
*/
80+
height: number;
81+
}

0 commit comments

Comments
 (0)