@rpg-engine/long-bow 0.1.67 → 0.1.70

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 (32) hide show
  1. package/dist/components/DraggableContainer.d.ts +2 -2
  2. package/dist/components/Item/Inventory/ItemContainer.d.ts +3 -3
  3. package/dist/components/Item/SpriteFromAtlas.d.ts +2 -0
  4. package/dist/components/Multitab/Tab.d.ts +9 -0
  5. package/dist/components/Multitab/TabBody.d.ts +7 -0
  6. package/dist/components/Multitab/TabsContainer.d.ts +17 -0
  7. package/dist/components/SimpleProgressBar.d.ts +3 -4
  8. package/dist/components/SkillProgressBar.d.ts +6 -4
  9. package/dist/components/SkillsContainer.d.ts +7 -0
  10. package/dist/constants/uiColors.d.ts +7 -0
  11. package/dist/long-bow.cjs.development.js +4011 -498
  12. package/dist/long-bow.cjs.development.js.map +1 -1
  13. package/dist/long-bow.cjs.production.min.js +1 -1
  14. package/dist/long-bow.cjs.production.min.js.map +1 -1
  15. package/dist/long-bow.esm.js +4012 -499
  16. package/dist/long-bow.esm.js.map +1 -1
  17. package/dist/mocks/skills.mocks.d.ts +115 -0
  18. package/package.json +3 -3
  19. package/src/components/DraggableContainer.tsx +11 -9
  20. package/src/components/I_Book.png +0 -0
  21. package/src/components/Item/Inventory/ItemContainer.tsx +14 -6
  22. package/src/components/Item/SpriteFromAtlas.tsx +10 -0
  23. package/src/components/Multitab/Tab.tsx +57 -0
  24. package/src/components/Multitab/TabBody.tsx +13 -0
  25. package/src/components/Multitab/TabsContainer.tsx +97 -0
  26. package/src/components/SimpleProgressBar.tsx +14 -10
  27. package/src/components/SkillProgressBar.tsx +74 -20
  28. package/src/components/SkillsContainer.tsx +235 -0
  29. package/src/constants/uiColors.ts +7 -0
  30. package/src/mocks/atlas/items/items.json +3920 -460
  31. package/src/mocks/atlas/items/items.png +0 -0
  32. package/src/mocks/skills.mocks.ts +116 -0
@@ -10,10 +10,10 @@ export interface IDraggableContainerProps {
10
10
  height?: string;
11
11
  className?: string;
12
12
  type?: RPGUIContainerTypes;
13
- title: string;
13
+ title?: string;
14
14
  imgSrc?: string;
15
15
  imgWidth?: string;
16
- onCloseButton: () => void;
16
+ onCloseButton?: () => void;
17
17
  cancelDrag?: string;
18
18
  onPositionChange?: (position: IPosition) => void;
19
19
  }
@@ -48,12 +48,14 @@ export const DraggableContainer: React.FC<IDraggableContainerProps> = ({
48
48
  height={height || 'auto'}
49
49
  className={`rpgui-container ${type} ${className}`}
50
50
  >
51
- <TitleContainer className="drag-handler">
52
- <Title>
53
- {imgSrc && <Icon src={imgSrc} width={imgWidth} />}
54
- {title}
55
- </Title>
56
- </TitleContainer>
51
+ {title && (
52
+ <TitleContainer className="drag-handler">
53
+ <Title>
54
+ {imgSrc && <Icon src={imgSrc} width={imgWidth} />}
55
+ {title}
56
+ </Title>
57
+ </TitleContainer>
58
+ )}
57
59
  {onCloseButton && (
58
60
  <CloseButton
59
61
  className="container-close"
@@ -101,7 +103,7 @@ const TitleContainer = styled.div`
101
103
  height: 100%;
102
104
  display: flex;
103
105
  flex-wrap: wrap;
104
- justify-content: center;
106
+ justify-content: flex-start;
105
107
  align-items: center;
106
108
  `;
107
109
 
Binary file
@@ -17,9 +17,9 @@ import { ItemSlot } from './ItemSlot';
17
17
 
18
18
  export interface IItemContainerProps {
19
19
  itemContainer: IItemContainer;
20
- onClose: () => void;
21
- onMouseOver: (e: any, slotIndex: number, item: IItem | null) => void;
22
- onActionSelected: (payload: any) => void;
20
+ onClose?: () => void;
21
+ onMouseOver?: (e: any, slotIndex: number, item: IItem | null) => void;
22
+ onActionSelected?: (payload: any) => void;
23
23
  initialPosition?: { x: number; y: number };
24
24
  }
25
25
 
@@ -111,7 +111,9 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
111
111
  posX: x - draggablePosition.x,
112
112
  posY: y - draggablePosition.y,
113
113
  });
114
- onMouseOver(event, slotIndex, item);
114
+ if (onMouseOver) {
115
+ onMouseOver(event, slotIndex, item);
116
+ }
115
117
  } else {
116
118
  clearItemHoverDetail();
117
119
  }
@@ -144,7 +146,9 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
144
146
  actionType: selectedActionId,
145
147
  item: contextData.slotItem,
146
148
  };
147
- onActionSelected(payloadData);
149
+ if (onActionSelected) {
150
+ onActionSelected(payloadData);
151
+ }
148
152
  clearContextMenu();
149
153
  };
150
154
 
@@ -173,7 +177,11 @@ export const ItemContainer: React.FC<IItemContainerProps> = ({
173
177
  <DraggableContainer
174
178
  title={itemContainer.name || 'Container'}
175
179
  type={RPGUIContainerTypes.Framed}
176
- onCloseButton={() => onClose()}
180
+ onCloseButton={() => {
181
+ if (onClose) {
182
+ onClose();
183
+ }
184
+ }}
177
185
  width="330px"
178
186
  cancelDrag=".item-container-body"
179
187
  onPositionChange={({ x, y }) => {
@@ -9,6 +9,8 @@ interface IProps {
9
9
  width?: number;
10
10
  height?: number;
11
11
  scale?: number;
12
+ grayScale?: boolean;
13
+ opacity?: number;
12
14
  }
13
15
 
14
16
  export const SpriteFromAtlas: React.FC<IProps> = ({
@@ -18,6 +20,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
18
20
  width = GRID_WIDTH,
19
21
  height = GRID_HEIGHT,
20
22
  scale = 2,
23
+ grayScale = false,
24
+ opacity = 1,
21
25
  }) => {
22
26
  //! 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).
23
27
  //!Due to React's limitations, we cannot import it from the public folder directly!
@@ -31,6 +35,8 @@ export const SpriteFromAtlas: React.FC<IProps> = ({
31
35
  atlasIMG={atlasIMG}
32
36
  frame={spriteData.frame}
33
37
  scale={scale}
38
+ grayScale={grayScale}
39
+ opacity={opacity}
34
40
  />
35
41
  </Container>
36
42
  );
@@ -45,6 +51,8 @@ interface IImgSpriteProps {
45
51
  h: number;
46
52
  };
47
53
  scale: number;
54
+ grayScale: boolean;
55
+ opacity: number;
48
56
  }
49
57
 
50
58
  interface IContainerProps {
@@ -66,4 +74,6 @@ const ImgSprite = styled.div<IImgSpriteProps>`
66
74
  position: relative;
67
75
  top: 8px;
68
76
  left: 8px;
77
+ filter: ${props => (props.grayScale ? 'grayscale(100%)' : 'none')};
78
+ opacity: ${props => props.opacity};
69
79
  `;
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import { MultitabType } from './TabsContainer';
4
+
5
+ export interface ISingleTab {
6
+ active: boolean;
7
+ label: string;
8
+ onClick: () => void;
9
+ type: MultitabType;
10
+ }
11
+
12
+ export const Tab: React.FC<ISingleTab> = ({ active, label, onClick, type }) => {
13
+ return (
14
+ <CustomTab activeTab={active} onClick={onClick} className={type}>
15
+ <p>{label}</p>
16
+ </CustomTab>
17
+ );
18
+ };
19
+
20
+ interface ICustomTab {
21
+ activeTab: boolean;
22
+ }
23
+
24
+ const CustomTab = styled.div<ICustomTab>`
25
+ width: 120px;
26
+ color: white;
27
+ font-size: 0.8rem;
28
+
29
+ &.gray {
30
+ border-left: 0.25rem solid rgba(0, 0, 0, 0.25);
31
+ border-right: 0.25rem solid rgba(0, 0, 0, 0.25);
32
+ border-top: 0.25rem solid rgba(0, 0, 0, 0.25);
33
+ background: ${props => (props.activeTab ? '#4E4A4E' : '#2b292b')};
34
+ }
35
+
36
+ &.brown {
37
+ border-left: 0.25rem solid #996d55;
38
+ border-right: 0.25rem solid #996d55;
39
+ border-top: 0.25rem solid #996d55;
40
+ background: ${props => (props.activeTab ? '#BF886A' : '#B67051')};
41
+ }
42
+
43
+ margin-right: 10px;
44
+ p {
45
+ text-align: center;
46
+ font-size: 0.6rem;
47
+
48
+ opacity: ${props => (props.activeTab ? '1' : '0.5')};
49
+ }
50
+
51
+ border-radius: 5px 5px 0 0;
52
+
53
+ z-index: ${props => (props.activeTab ? 1 : -1)};
54
+
55
+ position: relative;
56
+ top: 0.3rem;
57
+ `;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ interface IProps {
5
+ id: string;
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ export const TabBody: React.FC<IProps> = ({ id, children }) => {
10
+ return <Container data-tab-id={id}>{children}</Container>;
11
+ };
12
+
13
+ const Container = styled.div``;
@@ -0,0 +1,97 @@
1
+ import React, { useState } from 'react';
2
+ import styled from 'styled-components';
3
+ import { DraggableContainer } from '../DraggableContainer';
4
+ import { RPGUIContainerTypes } from '../RPGUIContainer';
5
+ import { Tab } from './Tab';
6
+
7
+ interface ITab {
8
+ label: string;
9
+ id: string;
10
+ }
11
+
12
+ export enum MultitabType {
13
+ Brown = 'brown',
14
+ Gray = 'gray',
15
+ }
16
+
17
+ export interface ITabsContainer {
18
+ children: React.ReactNode;
19
+ onCloseButton?: () => void;
20
+ tabs: ITab[];
21
+ type: MultitabType;
22
+ }
23
+
24
+ export const TabsContainer: React.FC<ITabsContainer> = ({
25
+ children,
26
+ onCloseButton,
27
+ tabs,
28
+ type = MultitabType.Brown,
29
+ }) => {
30
+ const [selectedTab, setSelectedTab] = useState(tabs[0].id); //by default the first one
31
+
32
+ const onRenderTabs = () =>
33
+ tabs.map((tab, index) => (
34
+ <Tab
35
+ type={type}
36
+ active={selectedTab === tab.id}
37
+ label={tab.label}
38
+ key={`${tab.label}_${index}`}
39
+ onClick={() => setSelectedTab(tab.id)}
40
+ >
41
+ {tab.label}
42
+ </Tab>
43
+ ));
44
+
45
+ const onGetContainerType = () => {
46
+ switch (type) {
47
+ case 'brown':
48
+ return RPGUIContainerTypes.FramedGold;
49
+ case 'gray':
50
+ return RPGUIContainerTypes.Framed;
51
+ }
52
+ };
53
+
54
+ return (
55
+ <DraggableContainer
56
+ onCloseButton={onCloseButton}
57
+ type={onGetContainerType()}
58
+ >
59
+ {onRenderTabs()}
60
+ <BodyContainer selectedTab={selectedTab} className={type}>
61
+ {children}
62
+ </BodyContainer>
63
+ </DraggableContainer>
64
+ );
65
+ };
66
+
67
+ interface IBodyContainer {
68
+ selectedTab: string;
69
+ }
70
+
71
+ const BodyContainer = styled.div<IBodyContainer>`
72
+ display: flex;
73
+ width: 100%;
74
+ height: 100%;
75
+ justify-content: space-between;
76
+
77
+ /* hide everything that is not data-tab-id selectedTab */
78
+ & > *:not([data-tab-id=${props => props.selectedTab}]) {
79
+ display: none;
80
+ }
81
+
82
+ &.brown {
83
+ border: 0.25rem solid #996D55;
84
+ background-color: #BF886A;
85
+ }
86
+
87
+
88
+ &.gray {
89
+ border: 0.25rem solid rgba(0, 0, 0, 0.25);
90
+ background-color: #4E4A4E;
91
+ }
92
+
93
+
94
+ border-radius: 5px;
95
+ padding: 0.5rem;
96
+
97
+ `;
@@ -1,20 +1,20 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
- interface IProps {
4
+ export interface ISimpleProgressBarProps {
5
5
  value: number;
6
- height?: string;
7
6
  bgColor?: string;
7
+ margin?: number;
8
8
  }
9
9
 
10
- export const SimpleProgressBar: React.FC<IProps> = ({
10
+ export const SimpleProgressBar: React.FC<ISimpleProgressBarProps> = ({
11
11
  value,
12
-
13
12
  bgColor = 'red',
13
+ margin = 20,
14
14
  }) => {
15
15
  return (
16
- <Container>
17
- <ProgressBarContainer>
16
+ <Container className="simple-progress-bar">
17
+ <ProgressBarContainer margin={margin}>
18
18
  <BackgroundBar>
19
19
  <Progress value={value} bgColor={bgColor} />
20
20
  </BackgroundBar>
@@ -34,16 +34,20 @@ const BackgroundBar = styled.span`
34
34
  background-color: rgba(0, 0, 0, 0.075);
35
35
  `;
36
36
 
37
- interface IProgressProps {
37
+ interface ISimpleProgressBarThemeProps {
38
38
  value: number;
39
39
  bgColor: string;
40
40
  }
41
41
 
42
42
  const Progress = styled.span`
43
- background-color: ${(props: IProgressProps) => props.bgColor};
44
- width: ${(props: IProgressProps) => props.value}%;
43
+ background-color: ${(props: ISimpleProgressBarThemeProps) => props.bgColor};
44
+ width: ${(props: ISimpleProgressBarThemeProps) => props.value}%;
45
45
  `;
46
46
 
47
+ interface ISimpleProgressBarTheme2Props {
48
+ margin: number;
49
+ }
50
+
47
51
  const ProgressBarContainer = styled.div`
48
52
  border-radius: 60px;
49
53
  border: 1px solid #282424;
@@ -53,6 +57,6 @@ const ProgressBarContainer = styled.div`
53
57
  display: block;
54
58
  height: 100%;
55
59
  }
56
-
57
60
  height: 8px;
61
+ margin-left: ${(props: ISimpleProgressBarTheme2Props) => props.margin}px;
58
62
  `;
@@ -1,42 +1,99 @@
1
+ import { getSPForLevel } from '@rpg-engine/shared';
1
2
  import React from 'react';
2
3
  import styled from 'styled-components';
3
- import imgSrcTemplate from './imgExp.png';
4
+ import atlasJSON from '../mocks/atlas/items/items.json';
5
+ import atlasIMG from '../mocks/atlas/items/items.png';
6
+ import { SpriteFromAtlas } from './Item/SpriteFromAtlas';
4
7
  import { SimpleProgressBar } from './SimpleProgressBar';
5
8
 
6
9
  export interface ISkillProgressBarProps {
7
- value: number;
8
-
9
- height: string;
10
+ skillName: string;
10
11
  bgColor: string;
11
- titleName: string;
12
-
13
- logoSrc?: string;
12
+ level: number;
13
+ skillPoints: number;
14
+ skillPointsToNextLevel?: number;
15
+ texturePath: string;
16
+ showSkillPoints?: boolean;
14
17
  }
15
18
 
16
19
  export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
17
- value,
18
20
  bgColor,
19
- titleName,
20
-
21
- logoSrc = imgSrcTemplate,
21
+ skillName,
22
+ level,
23
+ skillPoints,
24
+ texturePath,
25
+ showSkillPoints = true,
22
26
  }) => {
27
+ const spForNextLevel = getSPForLevel(level + 1);
28
+
29
+ const ratio = (skillPoints / spForNextLevel) * 100;
30
+
23
31
  return (
24
32
  <>
25
33
  <ProgressTitle>
26
- <TitleName>{titleName}</TitleName>
27
- <ValueDisplay>{value}</ValueDisplay>
34
+ <TitleName>{skillName}</TitleName>
35
+ <ValueDisplay>lv {level}</ValueDisplay>
28
36
  </ProgressTitle>
29
37
  <ProgressBody>
30
38
  <ProgressIconContainer>
31
- <Icon src={logoSrc} />
39
+ {atlasIMG && atlasJSON ? (
40
+ <SpriteContainer>
41
+ <SpriteFromAtlas
42
+ atlasIMG={atlasIMG}
43
+ atlasJSON={atlasJSON}
44
+ spriteKey={texturePath}
45
+ scale={1}
46
+ grayScale
47
+ opacity={0.5}
48
+ />
49
+ </SpriteContainer>
50
+ ) : (
51
+ <></>
52
+ )}
32
53
  </ProgressIconContainer>
33
54
 
34
- <SimpleProgressBar value={value} bgColor={bgColor} />
55
+ <ProgressBarContainer>
56
+ <SimpleProgressBar value={ratio} bgColor={bgColor} />
57
+ </ProgressBarContainer>
35
58
  </ProgressBody>
59
+ {showSkillPoints && (
60
+ <SkillDisplayContainer>
61
+ <SkillPointsDisplay>
62
+ {skillPoints}/{spForNextLevel}
63
+ </SkillPointsDisplay>
64
+ </SkillDisplayContainer>
65
+ )}
36
66
  </>
37
67
  );
38
68
  };
39
69
 
70
+ const ProgressBarContainer = styled.div`
71
+ position: relative;
72
+ top: 8px;
73
+ width: 100%;
74
+ height: auto;
75
+ `;
76
+
77
+ const SpriteContainer = styled.div`
78
+ position: relative;
79
+ top: -3px;
80
+ left: 0;
81
+ `;
82
+
83
+ const SkillDisplayContainer = styled.div`
84
+ margin: 5px auto;
85
+
86
+ p {
87
+ margin: 0;
88
+ }
89
+ `;
90
+
91
+ const SkillPointsDisplay = styled.p`
92
+ font-size: 0.6rem !important;
93
+ font-weight: bold;
94
+ text-align: center;
95
+ `;
96
+
40
97
  const TitleName = styled.span`
41
98
  margin-left: 5px;
42
99
  `;
@@ -52,6 +109,7 @@ const ProgressIconContainer = styled.div`
52
109
  const ProgressBody = styled.div`
53
110
  display: flex;
54
111
  flex-direction: row;
112
+ width: 100%;
55
113
  `;
56
114
 
57
115
  const ProgressTitle = styled.div`
@@ -62,9 +120,5 @@ const ProgressTitle = styled.div`
62
120
  span {
63
121
  font-size: 0.6rem;
64
122
  }
65
- `;
66
-
67
- const Icon = styled.img`
68
- margin-right: 10px;
69
- height: 30px;
123
+ margin-top: 10px;
70
124
  `;