@rpg-engine/long-bow 0.3.43 → 0.3.44

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 (115) hide show
  1. package/dist/components/Abstractions/SlotsContainer.d.ts +0 -1
  2. package/dist/components/Button.d.ts +2 -3
  3. package/dist/components/Chat/Chat.d.ts +2 -12
  4. package/dist/components/CheckButton.d.ts +2 -1
  5. package/dist/components/DraggableContainer.d.ts +0 -1
  6. package/dist/components/Equipment/EquipmentSet.d.ts +0 -8
  7. package/dist/components/Input.d.ts +0 -1
  8. package/dist/components/Item/Inventory/ItemContainer.d.ts +0 -12
  9. package/dist/components/Item/Inventory/ItemSlot.d.ts +0 -9
  10. package/dist/components/NPCDialog/NPCDialogText.d.ts +2 -4
  11. package/dist/components/RangeSlider.d.ts +0 -1
  12. package/dist/index.d.ts +0 -8
  13. package/dist/long-bow.cjs.development.js +515 -7465
  14. package/dist/long-bow.cjs.development.js.map +1 -1
  15. package/dist/long-bow.cjs.production.min.js +1 -1
  16. package/dist/long-bow.cjs.production.min.js.map +1 -1
  17. package/dist/long-bow.esm.js +520 -7461
  18. package/dist/long-bow.esm.js.map +1 -1
  19. package/dist/mocks/equipmentSet.mocks.d.ts +2 -15
  20. package/dist/mocks/skills.mocks.d.ts +121 -2
  21. package/package.json +2 -5
  22. package/src/components/Abstractions/SlotsContainer.tsx +0 -3
  23. package/src/components/Button.tsx +8 -18
  24. package/src/components/Chat/Chat.tsx +105 -106
  25. package/src/components/CheckButton.tsx +1 -1
  26. package/src/components/DraggableContainer.tsx +1 -4
  27. package/src/components/Dropdown.tsx +1 -7
  28. package/src/components/Equipment/EquipmentSet.tsx +0 -46
  29. package/src/components/Input.tsx +2 -6
  30. package/src/components/Item/Inventory/ItemContainer.tsx +6 -104
  31. package/src/components/Item/Inventory/ItemSlot.tsx +34 -234
  32. package/src/components/NPCDialog/NPCDialog.tsx +28 -4
  33. package/src/components/NPCDialog/NPCDialogText.tsx +15 -75
  34. package/src/components/RangeSlider.tsx +14 -37
  35. package/src/components/SkillsContainer.tsx +1 -1
  36. package/src/components/TimeWidget/TimeWidget.tsx +0 -1
  37. package/src/components/TradingMenu/TradingItemRow.tsx +6 -43
  38. package/src/components/TradingMenu/TradingMenu.tsx +1 -1
  39. package/src/components/TradingMenu/items.mock.ts +0 -1
  40. package/src/components/shared/SpriteFromAtlas.tsx +1 -4
  41. package/src/hooks/useOutsideAlerter.ts +2 -2
  42. package/src/index.tsx +0 -8
  43. package/src/mocks/atlas/items/items.json +314 -6086
  44. package/src/mocks/atlas/items/items.png +0 -0
  45. package/src/mocks/equipmentSet.mocks.ts +4 -49
  46. package/src/mocks/itemContainer.mocks.ts +6 -54
  47. package/src/mocks/skills.mocks.ts +2 -8
  48. package/src/stories/Chat.stories.tsx +3 -20
  49. package/src/stories/EquipmentSet.stories.tsx +0 -10
  50. package/src/stories/ItemContainer.stories.tsx +15 -84
  51. package/src/stories/RangeSlider.stories.tsx +9 -10
  52. package/dist/components/CaracterStatus/CaracterStatus.d.ts +0 -9
  53. package/dist/components/Chatdeprecated/ChatDeprecated.d.ts +0 -13
  54. package/dist/components/CircularController/CircularController.d.ts +0 -10
  55. package/dist/components/CraftBook/CraftBook.d.ts +0 -15
  56. package/dist/components/CraftBook/MockItems.d.ts +0 -2
  57. package/dist/components/DropdownSelectorContainer.d.ts +0 -13
  58. package/dist/components/Item/Inventory/ItemQuantitySelector.d.ts +0 -7
  59. package/dist/components/RadioInput/RadioButton.d.ts +0 -8
  60. package/dist/components/RadioInput/RadioInput.d.ts +0 -13
  61. package/dist/components/RadioInput/instruments.d.ts +0 -4
  62. package/dist/components/Spellbook/QuickSpells.d.ts +0 -10
  63. package/dist/components/Spellbook/Spell.d.ts +0 -11
  64. package/dist/components/Spellbook/Spellbook.d.ts +0 -15
  65. package/dist/components/Spellbook/SpellbookShortcuts.d.ts +0 -10
  66. package/dist/components/Spellbook/constants.d.ts +0 -3
  67. package/dist/components/Spellbook/mockSpells.d.ts +0 -2
  68. package/dist/components/itemSelector/ItemSelector.d.ts +0 -14
  69. package/dist/constants/uiDevices.d.ts +0 -1
  70. package/dist/stories/CaracterStatus.stories.d.ts +0 -5
  71. package/dist/stories/ChatDeprecated.stories.d.ts +0 -5
  72. package/dist/stories/CircullarController.stories.d.ts +0 -5
  73. package/dist/stories/CraftBook.stories.d.ts +0 -4
  74. package/dist/stories/DropdownSelectorContainer.stories.d.ts +0 -5
  75. package/dist/stories/ItemQuantitySelector.stories.d.ts +0 -5
  76. package/dist/stories/ItemSelector.stories.d.ts +0 -4
  77. package/dist/stories/QuickSpells.stories.d.ts +0 -5
  78. package/dist/stories/RadioInput.stories.d.ts +0 -5
  79. package/dist/stories/Spellbook.stories.d.ts +0 -5
  80. package/src/.DS_Store +0 -0
  81. package/src/components/.DS_Store +0 -0
  82. package/src/components/CaracterStatus/CaracterStatus.tsx +0 -86
  83. package/src/components/CaracterStatus/Character.png +0 -0
  84. package/src/components/Chatdeprecated/ChatDeprecated.tsx +0 -200
  85. package/src/components/CircularController/CircularController.tsx +0 -162
  86. package/src/components/CraftBook/CraftBook.tsx +0 -230
  87. package/src/components/CraftBook/MockItems.ts +0 -46
  88. package/src/components/DropdownSelectorContainer.tsx +0 -42
  89. package/src/components/Item/Inventory/ItemQuantitySelector.tsx +0 -142
  90. package/src/components/NPCDialog/.DS_Store +0 -0
  91. package/src/components/NPCDialog/img/.DS_Store +0 -0
  92. package/src/components/NPCDialog/img/press-button.gif +0 -0
  93. package/src/components/RadioInput/RadioButton.tsx +0 -98
  94. package/src/components/RadioInput/RadioInput.tsx +0 -99
  95. package/src/components/RadioInput/instruments.ts +0 -16
  96. package/src/components/Spellbook/QuickSpells.tsx +0 -120
  97. package/src/components/Spellbook/Spell.tsx +0 -201
  98. package/src/components/Spellbook/Spellbook.tsx +0 -144
  99. package/src/components/Spellbook/SpellbookShortcuts.tsx +0 -77
  100. package/src/components/Spellbook/constants.ts +0 -12
  101. package/src/components/Spellbook/mockSpells.ts +0 -60
  102. package/src/components/itemSelector/ItemSelector.tsx +0 -136
  103. package/src/constants/uiDevices.ts +0 -5
  104. package/src/mocks/.DS_Store +0 -0
  105. package/src/mocks/atlas/.DS_Store +0 -0
  106. package/src/stories/CaracterStatus.stories.tsx +0 -29
  107. package/src/stories/ChatDeprecated.stories.tsx +0 -170
  108. package/src/stories/CircullarController.stories.tsx +0 -33
  109. package/src/stories/CraftBook.stories.tsx +0 -40
  110. package/src/stories/DropdownSelectorContainer.stories.tsx +0 -41
  111. package/src/stories/ItemQuantitySelector.stories.tsx +0 -26
  112. package/src/stories/ItemSelector.stories.tsx +0 -77
  113. package/src/stories/QuickSpells.stories.tsx +0 -38
  114. package/src/stories/RadioInput.stories.tsx +0 -35
  115. package/src/stories/Spellbook.stories.tsx +0 -107
@@ -1,18 +1,13 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import styled from 'styled-components';
3
- import { NPCDialogType } from '../..';
4
- import { IS_MOBILE_OR_TABLET } from '../../constants/uiDevices';
5
3
  import { chunkString } from '../../libs/StringHelpers';
6
4
  import { DynamicText } from '../typography/DynamicText';
7
- import pressButtonGif from './img/press-button.gif';
8
- import pressSpaceGif from './img/space.gif';
9
5
 
10
6
  interface IProps {
11
7
  text: string;
12
8
  onClose: () => void;
13
- onEndStep?: () => void;
14
- onStartStep?: () => void;
15
- type?: NPCDialogType;
9
+ onEndStep: () => void;
10
+ onStartStep: () => void;
16
11
  }
17
12
 
18
13
  export const NPCDialogText: React.FC<IProps> = ({
@@ -20,43 +15,21 @@ export const NPCDialogText: React.FC<IProps> = ({
20
15
  onClose,
21
16
  onEndStep,
22
17
  onStartStep,
23
- type,
24
18
  }) => {
25
- const windowSize = useRef([window.innerWidth, window.innerHeight]);
26
- function maxCharacters(width: number) {
27
- // Set the font size to 16 pixels
28
- var fontSize = 11.2;
29
-
30
- // Calculate the number of characters that can fit in one line
31
- var charactersPerLine = Math.floor(width / 2 / fontSize);
32
-
33
- // Calculate the number of lines that can fit in the div
34
- var linesPerDiv = Math.floor(180 / fontSize);
35
-
36
- // Calculate the maximum number of characters that can fit in the div
37
- var maxCharacters = charactersPerLine * linesPerDiv;
38
-
39
- // Return the maximum number of characters
40
- return Math.round(maxCharacters / 5);
41
- }
42
-
43
- const textChunks = chunkString(text, maxCharacters(windowSize.current[0]));
19
+ const textChunks = chunkString(text, 200);
44
20
 
45
21
  const [chunkIndex, setChunkIndex] = useState<number>(0);
22
+
46
23
  const onHandleSpacePress = (event: KeyboardEvent) => {
47
24
  if (event.code === 'Space') {
48
- goToNextStep();
49
- }
50
- };
51
-
52
- const goToNextStep = () => {
53
- const hasNextChunk = textChunks?.[chunkIndex + 1] || false;
54
-
55
- if (hasNextChunk) {
56
- setChunkIndex(prev => prev + 1);
57
- } else {
58
- // if there's no more text chunks, close the dialog
59
- onClose();
25
+ const hasNextChunk = textChunks?.[chunkIndex + 1] || false;
26
+
27
+ if (hasNextChunk) {
28
+ setChunkIndex(prev => prev + 1);
29
+ } else {
30
+ // if there's no more text chunks, close the dialog
31
+ onClose();
32
+ }
60
33
  }
61
34
  };
62
35
 
@@ -66,48 +39,15 @@ export const NPCDialogText: React.FC<IProps> = ({
66
39
  return () => document.removeEventListener('keydown', onHandleSpacePress);
67
40
  }, [chunkIndex]);
68
41
 
69
- const [showGoNextIndicator, setShowGoNextIndicator] = useState<boolean>(
70
- false
71
- );
72
-
73
42
  return (
74
43
  <Container>
75
44
  <DynamicText
76
45
  text={textChunks?.[chunkIndex] || ''}
77
- onFinish={() => {
78
- setShowGoNextIndicator(true);
79
-
80
- onEndStep && onEndStep();
81
- }}
82
- onStart={() => {
83
- setShowGoNextIndicator(false);
84
-
85
- onStartStep && onStartStep();
86
- }}
46
+ onFinish={onEndStep}
47
+ onStart={onStartStep}
87
48
  />
88
- {showGoNextIndicator && (
89
- <PressSpaceIndicator
90
- right={type === NPCDialogType.TextOnly ? '1rem' : '10.5rem'}
91
- src={IS_MOBILE_OR_TABLET ? pressButtonGif : pressSpaceGif}
92
- onClick={() => {
93
- goToNextStep();
94
- }}
95
- />
96
- )}
97
49
  </Container>
98
50
  );
99
51
  };
100
52
 
101
53
  const Container = styled.div``;
102
-
103
- interface IPressSpaceIndicatorProps {
104
- right: string;
105
- }
106
-
107
- const PressSpaceIndicator = styled.img<IPressSpaceIndicatorProps>`
108
- position: absolute;
109
- right: ${({ right }) => right};
110
- bottom: 1rem;
111
- height: 20.7px;
112
- image-rendering: -webkit-optimize-contrast;
113
- `;
@@ -1,6 +1,7 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
+ import { _RPGUI } from './RPGUIRoot';
4
5
 
5
6
  export enum RangeSliderType {
6
7
  Slider = 'rpgui-slider',
@@ -13,7 +14,6 @@ export interface IRangeSliderProps {
13
14
  valueMax: number;
14
15
  width: string;
15
16
  onChange: (value: number) => void;
16
- value: number;
17
17
  }
18
18
 
19
19
  export const RangeSlider: React.FC<IRangeSliderProps> = ({
@@ -22,46 +22,29 @@ export const RangeSlider: React.FC<IRangeSliderProps> = ({
22
22
  valueMax,
23
23
  width,
24
24
  onChange,
25
- value,
26
25
  }) => {
27
26
  const sliderId = uuidv4();
28
27
 
29
- const containerRef = useRef<HTMLDivElement>(null);
30
- const [left, setLeft] = useState(0);
28
+ const onHandleMouseUp = () => {
29
+ const rpguiSlider = document.getElementById(`rpgui-slider-${sliderId}`);
30
+ const value = _RPGUI.get_value(rpguiSlider);
31
31
 
32
- useEffect(() => {
33
- const calculatedWidth = containerRef.current?.clientWidth || 0;
34
- setLeft(
35
- Math.max(
36
- ((value - valueMin) / (valueMax - valueMin)) * (calculatedWidth - 35) +
37
- 10
38
- )
39
- );
40
- }, [value, valueMin, valueMax]);
41
-
42
- const typeClass = type === RangeSliderType.GoldSlider ? 'golden' : '';
32
+ onChange(Number(value));
33
+ };
43
34
 
44
35
  return (
45
- <div
46
- style={{ width: width, position: 'relative' }}
47
- className={`rpgui-slider-container ${typeClass}`}
48
- id={`rpgui-slider-${sliderId}`}
49
- ref={containerRef}
50
- >
51
- <div style={{ pointerEvents: 'none' }}>
52
- <div className={`rpgui-slider-track ${typeClass}`} />
53
- <div className={`rpgui-slider-left-edge ${typeClass}`} />
54
- <div className={`rpgui-slider-right-edge ${typeClass}`} />
55
- <div className={`rpgui-slider-thumb ${typeClass}`} style={{ left }} />
56
- </div>
36
+ <div onMouseUp={onHandleMouseUp}>
57
37
  <Input
38
+ className={
39
+ type === RangeSliderType.Slider
40
+ ? RangeSliderType.Slider
41
+ : RangeSliderType.GoldSlider
42
+ }
58
43
  type="range"
59
44
  style={{ width: width }}
60
45
  min={valueMin}
61
46
  max={valueMax}
62
- onChange={e => onChange(Number(e.target.value))}
63
- value={value}
64
- className="rpgui-cursor-point"
47
+ id={`rpgui-slider-${sliderId}`}
65
48
  />
66
49
  </div>
67
50
  );
@@ -69,10 +52,4 @@ export const RangeSlider: React.FC<IRangeSliderProps> = ({
69
52
 
70
53
  const Input = styled.input`
71
54
  opacity: 0;
72
- position: absolute;
73
- width: 100%;
74
- height: 100%;
75
- top: 0;
76
- left: 0;
77
- margin-top: -5px;
78
55
  `;
@@ -163,5 +163,5 @@ const CloseButton = styled.div`
163
163
  right: 2px;
164
164
  color: white;
165
165
  z-index: 22;
166
- font-size: 1.1rem;
166
+ font-size: 0.7rem;
167
167
  `;
@@ -37,7 +37,6 @@ const WidgetContainer = styled.div`
37
37
  background-repeat: no-repeat;
38
38
  width: 10rem;
39
39
  position: absolute;
40
- height: 100px;
41
40
  `;
42
41
 
43
42
  const Time = styled.div`
@@ -1,4 +1,4 @@
1
- import { getItemTextureKeyPath, ITradeResponseItem } from '@rpg-engine/shared';
1
+ import { ITradeResponseItem } from '@rpg-engine/shared';
2
2
  import capitalize from 'lodash/capitalize';
3
3
  import React from 'react';
4
4
  import styled from 'styled-components';
@@ -37,18 +37,6 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
37
37
  onQuantityChange(traderItem, newQuantity);
38
38
  }
39
39
  };
40
- const onLeftOutClick = () => {
41
- if (selectedQty >= 10) {
42
- const newQuantity = selectedQty - 10;
43
- onQuantityChange(traderItem, newQuantity);
44
- }
45
- };
46
- const onRightOutClick = () => {
47
- if (selectedQty + 10 <= (traderItem.qty ?? 999)) {
48
- const newQuantity = selectedQty + 10;
49
- onQuantityChange(traderItem, newQuantity);
50
- }
51
- };
52
40
 
53
41
  return (
54
42
  <ItemWrapper>
@@ -57,14 +45,7 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
57
45
  <SpriteFromAtlas
58
46
  atlasIMG={atlasIMG}
59
47
  atlasJSON={atlasJSON}
60
- spriteKey={getItemTextureKeyPath(
61
- {
62
- key: traderItem.key,
63
- stackQty: traderItem.qty || 1,
64
- texturePath: traderItem.texturePath,
65
- },
66
- atlasJSON
67
- )}
48
+ spriteKey={traderItem.texturePath}
68
49
  imgScale={2.5}
69
50
  />
70
51
  </SpriteContainer>
@@ -82,47 +63,29 @@ export const TradingItemRow: React.FC<ITradeComponentProps> = ({
82
63
 
83
64
  <QuantityContainer>
84
65
  <SelectArrow
85
- size={32}
86
- className="arrow-selector"
87
- direction="left"
88
- onClick={onLeftOutClick}
89
- onTouchStart={onLeftOutClick}
90
- />
91
- <StyledArrow
92
66
  size={32}
93
67
  className="arrow-selector"
94
68
  direction="left"
95
69
  onClick={onLeftClick}
96
70
  onTouchStart={onLeftClick}
97
- />
71
+ ></SelectArrow>
98
72
  <QuantityDisplay>
99
73
  <TextOverlay>
100
74
  <Item>{selectedQty}</Item>
101
75
  </TextOverlay>
102
76
  </QuantityDisplay>
103
- <StyledArrow
77
+ <SelectArrow
104
78
  size={32}
105
79
  className="arrow-selector"
106
80
  direction="right"
107
81
  onClick={onRightClick}
108
82
  onTouchStart={onRightClick}
109
- />
110
- <SelectArrow
111
- size={32}
112
- className="arrow-selector"
113
- direction="right"
114
- onClick={onRightOutClick}
115
- onTouchStart={onRightOutClick}
116
- />
83
+ ></SelectArrow>
117
84
  </QuantityContainer>
118
85
  </ItemWrapper>
119
86
  );
120
87
  };
121
88
 
122
- const StyledArrow = styled(SelectArrow)`
123
- margin: 40px;
124
- `;
125
-
126
89
  const ItemWrapper = styled.div`
127
90
  width: 100%;
128
91
  margin: auto;
@@ -189,7 +152,7 @@ const QuantityContainer = styled.div<IContainerProps>`
189
152
  justify-content: center;
190
153
  align-items: center;
191
154
 
192
- flex: 40%;
155
+ flex: 20%;
193
156
  `;
194
157
 
195
158
  const QuantityDisplay = styled.div`
@@ -80,7 +80,7 @@ export const TradingMenu: React.FC<ITrandingMenu> = ({
80
80
  onCloseButton={() => {
81
81
  if (onClose) onClose();
82
82
  }}
83
- width="600px"
83
+ width="500px"
84
84
  cancelDrag=".equipment-container-body .arrow-selector"
85
85
  >
86
86
  <>
@@ -19,7 +19,6 @@ export const itemMock: ITradeResponseItem[] = [
19
19
  name: 'Silver Short Sword Premium',
20
20
  price: 100,
21
21
  key: SwordsBlueprint.IceSword,
22
- qty: 12
23
22
  },
24
23
  {
25
24
  texturePath: "swords/corruption-sword.png",
@@ -32,10 +32,7 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
32
32
  //! If an item is not showing, remember that you MUST run yarn atlas:copy everytime you add a new item to the atlas (it will sync our public folder atlas with src/atlas).
33
33
  //!Due to React's limitations, we cannot import it from the public folder directly!
34
34
 
35
- const spriteData =
36
- atlasJSON.frames[spriteKey] || atlasJSON.frames['others/no-image.png'];
37
-
38
- if (!spriteData) throw new Error(`Sprite ${spriteKey} not found in atlas!`);
35
+ const spriteData = atlasJSON.frames[spriteKey];
39
36
 
40
37
  return (
41
38
  <Container
@@ -16,10 +16,10 @@ export function useOutsideClick(ref: any, id: string) {
16
16
  }
17
17
  }
18
18
  // Bind the event listener
19
- document.addEventListener('pointerdown', handleClickOutside);
19
+ document.addEventListener('mousedown', handleClickOutside);
20
20
  return () => {
21
21
  // Unbind the event listener on clean up
22
- document.removeEventListener('pointerdown', handleClickOutside);
22
+ document.removeEventListener('mousedown', handleClickOutside);
23
23
  };
24
24
  }, [ref]);
25
25
  }
package/src/index.tsx CHANGED
@@ -1,20 +1,14 @@
1
1
  export * from './components/Button';
2
2
  export * from './components/Character/CharacterSelection';
3
3
  export * from './components/Chat/Chat';
4
- export * from './components/Chatdeprecated/ChatDeprecated';
5
4
  export * from './components/CheckButton';
6
- export * from './components/CircularController/CircularController';
7
- export * from './components/CraftBook/CraftBook';
8
5
  export * from './components/DraggableContainer';
9
6
  export * from './components/Dropdown';
10
- export * from './components/DropdownSelectorContainer';
11
7
  export * from './components/Equipment/EquipmentSet';
12
8
  export * from './components/HistoryDialog';
13
9
  export * from './components/Input';
14
- export { ErrorBoundary } from './components/Item/Inventory/ErrorBoundary';
15
10
  export * from './components/Item/Inventory/ItemContainer';
16
11
  export * from './components/Item/Inventory/ItemSlot';
17
- export * from './components/itemSelector/ItemSelector';
18
12
  export * from './components/ListMenu';
19
13
  export * from './components/NPCDialog/NPCDialog';
20
14
  export * from './components/NPCDialog/NPCMultiDialog';
@@ -30,8 +24,6 @@ export * from './components/RPGUIRoot';
30
24
  export * from './components/shared/SpriteFromAtlas';
31
25
  export * from './components/SkillProgressBar';
32
26
  export * from './components/SkillsContainer';
33
- export * from './components/Spellbook/QuickSpells';
34
- export * from './components/Spellbook/Spellbook';
35
27
  export * from './components/TextArea';
36
28
  export * from './components/TimeWidget/TimeWidget';
37
29
  export * from './components/TradingMenu/TradingMenu';