@rpg-engine/long-bow 0.3.44 → 0.3.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/components/Abstractions/SlotsContainer.d.ts +1 -0
  2. package/dist/components/Button.d.ts +3 -2
  3. package/dist/components/Chat/Chat.d.ts +12 -2
  4. package/dist/components/Chatdeprecated/ChatDeprecated.d.ts +13 -0
  5. package/dist/components/CheckButton.d.ts +1 -2
  6. package/dist/components/CircularController/CircularController.d.ts +10 -0
  7. package/dist/components/CraftBook/CraftBook.d.ts +15 -0
  8. package/dist/components/CraftBook/MockItems.d.ts +2 -0
  9. package/dist/components/DraggableContainer.d.ts +1 -0
  10. package/dist/components/DropdownSelectorContainer.d.ts +13 -0
  11. package/dist/components/Equipment/EquipmentSet.d.ts +8 -0
  12. package/dist/components/Input.d.ts +1 -0
  13. package/dist/components/Item/Inventory/ItemContainer.d.ts +12 -0
  14. package/dist/components/Item/Inventory/ItemQuantitySelector.d.ts +7 -0
  15. package/dist/components/Item/Inventory/ItemSlot.d.ts +9 -0
  16. package/dist/components/NPCDialog/NPCDialogText.d.ts +4 -2
  17. package/dist/components/RadioInput/RadioButton.d.ts +8 -0
  18. package/dist/components/RadioInput/RadioInput.d.ts +13 -0
  19. package/dist/components/RadioInput/instruments.d.ts +4 -0
  20. package/dist/components/RangeSlider.d.ts +1 -0
  21. package/dist/components/Spellbook/QuickSpells.d.ts +10 -0
  22. package/dist/components/Spellbook/Spell.d.ts +11 -0
  23. package/dist/components/Spellbook/Spellbook.d.ts +15 -0
  24. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +10 -0
  25. package/dist/components/Spellbook/constants.d.ts +3 -0
  26. package/dist/components/Spellbook/mockSpells.d.ts +2 -0
  27. package/dist/components/itemSelector/ItemSelector.d.ts +14 -0
  28. package/dist/constants/uiDevices.d.ts +1 -0
  29. package/dist/index.d.ts +8 -0
  30. package/dist/long-bow.cjs.development.js +7464 -515
  31. package/dist/long-bow.cjs.development.js.map +1 -1
  32. package/dist/long-bow.cjs.production.min.js +1 -1
  33. package/dist/long-bow.cjs.production.min.js.map +1 -1
  34. package/dist/long-bow.esm.js +7458 -518
  35. package/dist/long-bow.esm.js.map +1 -1
  36. package/dist/mocks/equipmentSet.mocks.d.ts +15 -2
  37. package/dist/mocks/skills.mocks.d.ts +2 -121
  38. package/dist/stories/ChatDeprecated.stories.d.ts +5 -0
  39. package/dist/stories/CircullarController.stories.d.ts +5 -0
  40. package/dist/stories/CraftBook.stories.d.ts +4 -0
  41. package/dist/stories/DropdownSelectorContainer.stories.d.ts +5 -0
  42. package/dist/stories/ItemQuantitySelector.stories.d.ts +5 -0
  43. package/dist/stories/ItemSelector.stories.d.ts +4 -0
  44. package/dist/stories/QuickSpells.stories.d.ts +5 -0
  45. package/dist/stories/RadioInput.stories.d.ts +5 -0
  46. package/dist/stories/Spellbook.stories.d.ts +5 -0
  47. package/package.json +5 -2
  48. package/src/components/Abstractions/SlotsContainer.tsx +3 -0
  49. package/src/components/Button.tsx +18 -8
  50. package/src/components/Chat/Chat.tsx +105 -105
  51. package/src/components/Chatdeprecated/ChatDeprecated.tsx +200 -0
  52. package/src/components/CheckButton.tsx +1 -1
  53. package/src/components/CircularController/CircularController.tsx +162 -0
  54. package/src/components/CraftBook/CraftBook.tsx +230 -0
  55. package/src/components/CraftBook/MockItems.ts +46 -0
  56. package/src/components/DraggableContainer.tsx +4 -1
  57. package/src/components/Dropdown.tsx +7 -1
  58. package/src/components/DropdownSelectorContainer.tsx +42 -0
  59. package/src/components/Equipment/EquipmentSet.tsx +46 -0
  60. package/src/components/Input.tsx +6 -2
  61. package/src/components/Item/Inventory/ItemContainer.tsx +104 -6
  62. package/src/components/Item/Inventory/ItemQuantitySelector.tsx +142 -0
  63. package/src/components/Item/Inventory/ItemSlot.tsx +234 -34
  64. package/src/components/NPCDialog/NPCDialog.tsx +4 -28
  65. package/src/components/NPCDialog/NPCDialogText.tsx +75 -15
  66. package/src/components/NPCDialog/img/press-button.gif +0 -0
  67. package/src/components/RadioInput/RadioButton.tsx +98 -0
  68. package/src/components/RadioInput/RadioInput.tsx +99 -0
  69. package/src/components/RadioInput/instruments.ts +16 -0
  70. package/src/components/RangeSlider.tsx +37 -14
  71. package/src/components/SkillsContainer.tsx +1 -1
  72. package/src/components/Spellbook/QuickSpells.tsx +120 -0
  73. package/src/components/Spellbook/Spell.tsx +201 -0
  74. package/src/components/Spellbook/Spellbook.tsx +144 -0
  75. package/src/components/Spellbook/SpellbookShortcuts.tsx +77 -0
  76. package/src/components/Spellbook/constants.ts +12 -0
  77. package/src/components/Spellbook/mockSpells.ts +60 -0
  78. package/src/components/TimeWidget/TimeWidget.tsx +1 -0
  79. package/src/components/TradingMenu/TradingItemRow.tsx +43 -6
  80. package/src/components/TradingMenu/TradingMenu.tsx +1 -1
  81. package/src/components/itemSelector/ItemSelector.tsx +136 -0
  82. package/src/components/shared/SpriteFromAtlas.tsx +4 -1
  83. package/src/constants/uiDevices.ts +5 -0
  84. package/src/hooks/useOutsideAlerter.ts +2 -2
  85. package/src/index.tsx +8 -0
  86. package/src/mocks/atlas/items/items.json +6086 -314
  87. package/src/mocks/atlas/items/items.png +0 -0
  88. package/src/mocks/equipmentSet.mocks.ts +49 -4
  89. package/src/mocks/itemContainer.mocks.ts +54 -6
  90. package/src/mocks/skills.mocks.ts +8 -2
  91. package/src/stories/Chat.stories.tsx +20 -3
  92. package/src/stories/ChatDeprecated.stories.tsx +170 -0
  93. package/src/stories/CircullarController.stories.tsx +33 -0
  94. package/src/stories/CraftBook.stories.tsx +40 -0
  95. package/src/stories/DropdownSelectorContainer.stories.tsx +41 -0
  96. package/src/stories/EquipmentSet.stories.tsx +10 -0
  97. package/src/stories/ItemContainer.stories.tsx +84 -15
  98. package/src/stories/ItemQuantitySelector.stories.tsx +26 -0
  99. package/src/stories/ItemSelector.stories.tsx +77 -0
  100. package/src/stories/QuickSpells.stories.tsx +38 -0
  101. package/src/stories/RadioInput.stories.tsx +35 -0
  102. package/src/stories/RangeSlider.stories.tsx +10 -9
  103. package/src/stories/Spellbook.stories.tsx +107 -0
@@ -9,6 +9,7 @@ import { RPGUIRoot } from '../../src/components/RPGUIRoot';
9
9
  import { equipmentSetMock } from '../../src/mocks/equipmentSet.mocks';
10
10
  import atlasJSON from '../mocks/atlas/items/items.json';
11
11
  import atlasIMG from '../mocks/atlas/items/items.png';
12
+ import { IPosition } from '../types/eventTypes';
12
13
 
13
14
  const meta: Meta = {
14
15
  title: 'Equipment Set',
@@ -36,6 +37,10 @@ const onSelected = (payload: string) => {
36
37
  console.log('dispatch', payload);
37
38
  };
38
39
 
40
+ const onItemOutsideDrop = (item: IItem, position: IPosition) => {
41
+ console.log('dropped outside', item, position);
42
+ };
43
+
39
44
  const Template: Story<IEquipmentSetProps> = args => (
40
45
  <RPGUIRoot>
41
46
  <EquipmentSet
@@ -45,9 +50,14 @@ const Template: Story<IEquipmentSetProps> = args => (
45
50
  onMouseOver={onMouseOver}
46
51
  onSelected={onSelected}
47
52
  onItemClick={onItemClick}
53
+ onItemDragEnd={_quantity => {}}
54
+ onItemDragStart={item => console.log('drag start: ', item._id)}
55
+ onItemPlaceDrop={item => console.log('dropped to: ', item?._id)}
56
+ checkIfItemCanBeMoved={() => false}
48
57
  type={ItemContainerType.Equipment}
49
58
  atlasIMG={atlasIMG}
50
59
  atlasJSON={atlasJSON}
60
+ onItemOutsideDrop={onItemOutsideDrop}
51
61
  />
52
62
  </RPGUIRoot>
53
63
  );
@@ -1,6 +1,6 @@
1
1
  import { IItem, ItemContainerType, ItemType } from '@rpg-engine/shared';
2
2
  import { Meta, Story } from '@storybook/react';
3
- import React from 'react';
3
+ import React, { useState } from 'react';
4
4
  import {
5
5
  IItemContainerProps,
6
6
  ItemContainer,
@@ -37,19 +37,88 @@ const onItemClick = (
37
37
  console.log(item, ItemType, itemContainerType, 'was clicked!');
38
38
  };
39
39
 
40
- const Template: Story<IItemContainerProps> = () => (
41
- <RPGUIRoot>
42
- <ItemContainer
43
- itemContainer={itemContainerMock}
44
- onClose={() => console.log('closing item container')}
45
- onMouseOver={onMouseOver}
46
- onSelected={onSelected}
47
- onItemClick={onItemClick}
48
- type={ItemContainerType.Inventory}
49
- atlasIMG={atlasIMG}
50
- atlasJSON={atlasJSON}
51
- />
52
- </RPGUIRoot>
53
- );
40
+ // THIS IS ONLY LONG-BOW EXAMPLE FOR DRAG AND DROP
41
+ let dragItem: IItem | null = null;
42
+ let dropItem: IItem | null = null;
43
+ let allowedToDrop = false;
44
+ let dragSlot = -1;
45
+ let dropSlot = -1;
46
+
47
+ const Template: Story<IItemContainerProps> = () => {
48
+ const [itemContainer, setItemContainer] = useState(itemContainerMock);
49
+
50
+ return (
51
+ <RPGUIRoot>
52
+ <ItemContainer
53
+ itemContainer={itemContainer}
54
+ onClose={() => console.log('closing item container')}
55
+ onMouseOver={onMouseOver}
56
+ onSelected={onSelected}
57
+ onItemClick={onItemClick}
58
+ checkIfItemCanBeMoved={() => allowedToDrop}
59
+ onItemDragEnd={quantity => {
60
+ // THIS IS ONLY LONG-BOW EXAMPLE FOR DRAG AND DROP
61
+
62
+ if (quantity === 0) {
63
+ setItemContainer({ ...itemContainer });
64
+ } else if (allowedToDrop && dropSlot !== -1) {
65
+ const newContainer = { ...itemContainer };
66
+
67
+ if (quantity && dragItem && dragItem.stackQty) {
68
+ newContainer.slots[dropSlot] = {
69
+ ...dragItem,
70
+ stackQty: quantity + (dropItem?.stackQty || 0),
71
+ };
72
+
73
+ if (dragItem.stackQty - quantity === 0)
74
+ newContainer.slots[dragSlot] = null;
75
+ else
76
+ newContainer.slots[dragSlot] = {
77
+ ...dragItem,
78
+ stackQty: dragItem.stackQty - quantity,
79
+ };
80
+ } else {
81
+ newContainer.slots[dropSlot] = dragItem;
82
+ newContainer.slots[dragSlot] = null;
83
+ }
84
+ setTimeout(() => {
85
+ setItemContainer(newContainer);
86
+ }, 100);
87
+ }
88
+
89
+ allowedToDrop = false;
90
+ dropSlot = -1;
91
+ dropItem = null;
92
+ dragItem = null;
93
+ }}
94
+ onItemDragStart={(item, slotIndex) => {
95
+ dragItem = item;
96
+ dragSlot = slotIndex;
97
+ }}
98
+ onItemPlaceDrop={(item, slotIndex) => {
99
+ // THIS IS ONLY LONG-BOW EXAMPLE FOR DRAG AND DROP
100
+
101
+ if (
102
+ !item ||
103
+ (dragItem?.key === item?.key && dragSlot !== slotIndex)
104
+ ) {
105
+ console.log('allow');
106
+ allowedToDrop = true;
107
+ dropSlot = slotIndex;
108
+ dropItem = item ? item : null;
109
+ } else {
110
+ allowedToDrop = false;
111
+ dropSlot = -1;
112
+ dropItem = null;
113
+ }
114
+ }}
115
+ onOutsideDrop={(item, pos) => console.log('drop', item, pos)}
116
+ type={ItemContainerType.Inventory}
117
+ atlasIMG={atlasIMG}
118
+ atlasJSON={atlasJSON}
119
+ />
120
+ </RPGUIRoot>
121
+ );
122
+ };
54
123
 
55
124
  export const Default = Template.bind({});
@@ -0,0 +1,26 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '..';
4
+ import {
5
+ IItemQuantitySelectorProps,
6
+ ItemQuantitySelector,
7
+ } from '../components/Item/Inventory/ItemQuantitySelector';
8
+
9
+ const meta: Meta = {
10
+ title: 'Item Quantity Selector',
11
+ component: ItemQuantitySelector,
12
+ };
13
+
14
+ export default meta;
15
+
16
+ const Template: Story<IItemQuantitySelectorProps> = args => (
17
+ <RPGUIRoot>
18
+ <ItemQuantitySelector {...args} />
19
+ </RPGUIRoot>
20
+ );
21
+
22
+ export const Default = Template.bind({});
23
+
24
+ Default.args = {
25
+ quantity: 10,
26
+ };
@@ -0,0 +1,77 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '..';
4
+ import {
5
+ IOptionsItemSelectorProps,
6
+ ItemSelector,
7
+ } from '../components/itemSelector/ItemSelector';
8
+ import atlasJSON from '../mocks/atlas/items/items.json';
9
+ import atlasIMG from '../mocks/atlas/items/items.png';
10
+
11
+ const meta: Meta = {
12
+ title: 'Item Selector',
13
+ component: ItemSelector,
14
+ };
15
+
16
+ export default meta;
17
+
18
+ const Template: Story = args => (
19
+ <RPGUIRoot>
20
+ <ItemSelector
21
+ atlasIMG={atlasIMG}
22
+ atlasJSON={atlasJSON}
23
+ options={options}
24
+ onSelect={onSelect}
25
+ onClose={() => console.log('closing Equipment Set Container')}
26
+ {...args}
27
+ />
28
+ </RPGUIRoot>
29
+ );
30
+
31
+ export const Default = Template.bind({});
32
+
33
+ const onSelect = (value: string): void => {
34
+ console.log('Story package', value);
35
+ };
36
+
37
+ const options: IOptionsItemSelectorProps[] = [
38
+ {
39
+ name: 'Human',
40
+ description: 'Human',
41
+ imageKey: 'axes/frost-double-axe.png',
42
+ },
43
+ {
44
+ name: 'Human',
45
+ description: 'Human',
46
+ imageKey: 'maces/spiked-club.png',
47
+ },
48
+ {
49
+ name: 'Human2',
50
+ description: 'Human2',
51
+ imageKey: 'axes/frost-double-axe.png',
52
+ },
53
+ {
54
+ name: 'Human3',
55
+ description: 'Human3',
56
+ imageKey: 'maces/spiked-club.png',
57
+ },
58
+ {
59
+ name: 'Human4',
60
+ description: 'Human4',
61
+ imageKey: 'axes/frost-double-axe.png',
62
+ },
63
+ {
64
+ name: 'Human5',
65
+ description: 'Human5',
66
+ imageKey: 'maces/spiked-club.png',
67
+ },
68
+ {
69
+ name: 'Human6',
70
+ description: 'Human6',
71
+ imageKey: 'axes/frost-double-axe.png',
72
+ },
73
+ ];
74
+
75
+ Default.args = {
76
+ options,
77
+ };
@@ -0,0 +1,38 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '../components/RPGUIRoot';
4
+ import { SPELL_SHORTCUTS_STORAGE_KEY } from '../components/Spellbook/constants';
5
+ import {
6
+ QuickSpells,
7
+ QuickSpellsProps,
8
+ } from '../components/Spellbook/QuickSpells';
9
+
10
+ const meta: Meta = {
11
+ title: 'QuickSpells',
12
+ component: QuickSpells,
13
+ };
14
+
15
+ export default meta;
16
+
17
+ const Template: Story<QuickSpellsProps> = args => {
18
+ return (
19
+ <RPGUIRoot>
20
+ <div
21
+ style={{
22
+ width: '100%',
23
+ }}
24
+ >
25
+ <QuickSpells {...args} />
26
+ </div>
27
+ </RPGUIRoot>
28
+ );
29
+ };
30
+
31
+ export const Default = Template.bind({});
32
+ Default.args = {
33
+ onSpellCast: spellKey => console.log(spellKey),
34
+ quickSpells: JSON.parse(
35
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
36
+ ),
37
+ mana: 100,
38
+ };
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import { RadioInput ,IRadioInput} from '../components/RadioInput/RadioInput';
4
+ import { RPGUIRoot } from '../components/RPGUIRoot';
5
+ import { Itools } from '../components/RadioInput/instruments';
6
+
7
+ const meta: Meta = {
8
+ component: RadioInput,
9
+ };
10
+
11
+ export default meta;
12
+ const Template: Story<IRadioInput> = args => (
13
+ <RPGUIRoot>
14
+ <RadioInput {...args} />
15
+ </RPGUIRoot>
16
+ );
17
+
18
+ export const RadioInputElement = Template.bind({});
19
+
20
+ const onSelectIt = (value:string):void => {
21
+ console.log('Story package', value);
22
+ };
23
+
24
+ const onClose = () => {
25
+ console.log('close');
26
+ };
27
+
28
+ RadioInputElement.args={
29
+ title:"Harvesting instruments",
30
+ subtitle:'Use the tool, you need it',
31
+ onSelect:onSelectIt,
32
+ onCancel:onClose,
33
+ items:Itools
34
+
35
+ }
@@ -1,5 +1,5 @@
1
1
  import { Meta, Story } from '@storybook/react';
2
- import React from 'react';
2
+ import React, { useState } from 'react';
3
3
  import {
4
4
  IRangeSliderProps,
5
5
  RangeSlider,
@@ -43,11 +43,15 @@ const meta: Meta = {
43
43
 
44
44
  export default meta;
45
45
 
46
- const Template: Story<IRangeSliderProps> = args => (
47
- <RPGUIRoot>
48
- <RangeSlider {...args} />
49
- </RPGUIRoot>
50
- );
46
+ const Template: Story<IRangeSliderProps> = args => {
47
+ const [value, setValue] = useState(50);
48
+
49
+ return (
50
+ <RPGUIRoot>
51
+ <RangeSlider {...args} value={value} onChange={setValue} />
52
+ </RPGUIRoot>
53
+ );
54
+ };
51
55
 
52
56
  // By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
53
57
  // https://storybook.js.org/docs/react/workflows/unit-testing
@@ -57,7 +61,4 @@ Default.args = {
57
61
  type: RangeSliderType.Slider,
58
62
  valueMin: 0,
59
63
  valueMax: 100,
60
- onChange: n => {
61
- console.log('onChange', n);
62
- },
63
64
  };
@@ -0,0 +1,107 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React, { useEffect, useState } from 'react';
3
+ import { RPGUIRoot } from '../components/RPGUIRoot';
4
+ import {
5
+ defaultSpellShortcut,
6
+ SPELL_SHORTCUTS_STORAGE_KEY,
7
+ } from '../components/Spellbook/constants';
8
+ import { mockSpells } from '../components/Spellbook/mockSpells';
9
+ import { ISpellbookProps, Spellbook } from '../components/Spellbook/Spellbook';
10
+
11
+ const meta: Meta = {
12
+ title: 'Spellbook',
13
+ component: Spellbook,
14
+ };
15
+
16
+ export default meta;
17
+
18
+ const Template: Story<ISpellbookProps> = args => {
19
+ const [spellShortcuts, setSpellShortcuts] = useState([]);
20
+
21
+ useEffect(() => {
22
+ const shortcuts = localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY);
23
+ if (shortcuts) {
24
+ setSpellShortcuts(JSON.parse(shortcuts));
25
+ }
26
+ }, []);
27
+
28
+ const setSpellShortcut = (key: string, index: number) => {
29
+ const spellShortcuts = JSON.parse(
30
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
31
+ );
32
+
33
+ const spell = mockSpells.find(s => s.key === key);
34
+ if (!spell) {
35
+ return;
36
+ }
37
+
38
+ if (!spellShortcuts) {
39
+ const newSpellShortcuts = [
40
+ defaultSpellShortcut,
41
+ defaultSpellShortcut,
42
+ defaultSpellShortcut,
43
+ defaultSpellShortcut,
44
+ ];
45
+
46
+ newSpellShortcuts[index] = spell;
47
+
48
+ localStorage.setItem(
49
+ SPELL_SHORTCUTS_STORAGE_KEY,
50
+ JSON.stringify(newSpellShortcuts)
51
+ );
52
+ } else {
53
+ spellShortcuts[index] = spell;
54
+
55
+ localStorage.setItem(
56
+ SPELL_SHORTCUTS_STORAGE_KEY,
57
+ JSON.stringify(spellShortcuts)
58
+ );
59
+ }
60
+
61
+ setSpellShortcuts(spellShortcuts);
62
+ };
63
+
64
+ const removeSpellShortcut = (index: number) => {
65
+ const spellShortcuts = JSON.parse(
66
+ localStorage.getItem(SPELL_SHORTCUTS_STORAGE_KEY) as string
67
+ );
68
+
69
+ if (!spellShortcuts) return;
70
+
71
+ spellShortcuts[index] = defaultSpellShortcut;
72
+
73
+ localStorage.setItem(
74
+ SPELL_SHORTCUTS_STORAGE_KEY,
75
+ JSON.stringify(spellShortcuts)
76
+ );
77
+
78
+ setSpellShortcuts(spellShortcuts);
79
+ };
80
+
81
+ return (
82
+ <RPGUIRoot>
83
+ <div
84
+ style={{
85
+ width: '50%',
86
+ height: '75%',
87
+ }}
88
+ >
89
+ <Spellbook
90
+ {...args}
91
+ setSpellShortcut={setSpellShortcut}
92
+ removeSpellShortcut={removeSpellShortcut}
93
+ spellShortcuts={spellShortcuts}
94
+ />
95
+ </div>
96
+ </RPGUIRoot>
97
+ );
98
+ };
99
+
100
+ export const Default = Template.bind({});
101
+ Default.args = {
102
+ onClose: () => console.log('close'),
103
+ onSpellClick: spellKey => console.log(spellKey),
104
+ spells: mockSpells,
105
+ magicLevel: 3,
106
+ mana: 5,
107
+ };