@rpg-engine/long-bow 0.2.44 → 0.2.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.
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { IPeriodOfDayDisplayProps } from '../components/TimeWidget/DayNightPeriod/DayNightPeriod';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IPeriodOfDayDisplayProps>;
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { IStaticBookProps } from '../components/StaticBook/StaticBook';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IStaticBookProps>;
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/react';
2
+ import { IClockWidgetProps } from '../components/TimeWidget/TimeWidget';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ export declare const Default: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, IClockWidgetProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -83,7 +83,7 @@
83
83
  },
84
84
  "dependencies": {
85
85
  "@rollup/plugin-image": "^2.1.1",
86
- "@rpg-engine/shared": "^0.5.70",
86
+ "@rpg-engine/shared": "^0.5.72",
87
87
  "dayjs": "^1.11.2",
88
88
  "fs-extra": "^10.1.0",
89
89
  "lodash": "^4.17.21",
@@ -0,0 +1,105 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Draggable from 'react-draggable';
3
+ import styled from 'styled-components';
4
+ import { uiFonts } from '../../constants/uiFonts';
5
+ import SelectArrow from '../Arrow/SelectArrow';
6
+ import Book from './img/0.png';
7
+
8
+ export interface IStaticBookProps {
9
+ content: string;
10
+ onChange?: (slice: string) => void;
11
+ onClose?: () => void;
12
+ }
13
+
14
+ export const StaticBook: React.FC<IStaticBookProps> = ({
15
+ content,
16
+ onChange,
17
+ onClose,
18
+ }) => {
19
+ const [currentIndex, setCurrentIndex] = useState(0);
20
+
21
+ // create slicedContent with string sliced every 550 characters
22
+ const slicedContent = content.match(/.{1,550}/g) || [];
23
+
24
+ useEffect(() => {
25
+ if (onChange) onChange(slicedContent[currentIndex]);
26
+ }, [currentIndex]);
27
+
28
+ const bookLength = slicedContent.length - 1;
29
+
30
+ const onLeftClick = () => {
31
+ if (currentIndex === 0) setCurrentIndex(bookLength);
32
+ else setCurrentIndex(index => index - 1);
33
+ };
34
+ const onRightClick = () => {
35
+ if (currentIndex === bookLength) setCurrentIndex(0);
36
+ else setCurrentIndex(index => index + 1);
37
+ };
38
+
39
+ const getCurrentContentSlice = () => {
40
+ return slicedContent[currentIndex];
41
+ };
42
+
43
+ return (
44
+ <Draggable>
45
+ <Container>
46
+ <CloseButton onClick={onClose}>X</CloseButton>
47
+ <ColumnBook isLastPage={currentIndex === bookLength}>
48
+ {getCurrentContentSlice()}
49
+ </ColumnBook>
50
+
51
+ <ArrowContainer>
52
+ {currentIndex >= 1 && (
53
+ <SelectArrow
54
+ direction="left"
55
+ onClick={onLeftClick}
56
+ onTouchStart={onLeftClick}
57
+ ></SelectArrow>
58
+ )}
59
+ {currentIndex !== bookLength && (
60
+ <SelectArrow
61
+ direction="right"
62
+ onClick={onRightClick}
63
+ onTouchStart={onRightClick}
64
+ ></SelectArrow>
65
+ )}
66
+ </ArrowContainer>
67
+ </Container>
68
+ </Draggable>
69
+ );
70
+ };
71
+
72
+ const Container = styled.div`
73
+ background-image: url(${Book});
74
+ background-repeat: no-repeat;
75
+ position: relative;
76
+ width: 778px;
77
+ height: 463px;
78
+ background-position-y: -1rem;
79
+ `;
80
+
81
+ const CloseButton = styled.p`
82
+ position: absolute;
83
+ top: 1.9rem;
84
+ right: 5rem;
85
+ font-size: ${uiFonts.size.large} !important;
86
+ `;
87
+
88
+ interface IColumnBook {
89
+ isLastPage: boolean;
90
+ }
91
+
92
+ const ColumnBook = styled.span<IColumnBook>`
93
+ position: absolute;
94
+ left: 5.2rem;
95
+ top: 3.8rem;
96
+ width: ${({ isLastPage }) => (!isLastPage ? '77%' : '37%')};
97
+ column-count: ${({ isLastPage }) => (isLastPage ? 1 : 2)};
98
+ grid-gap: 56px;
99
+ min-height: 340px;
100
+ `;
101
+ const ArrowContainer = styled.span`
102
+ display: flex;
103
+ height: 100%;
104
+ align-items: center;
105
+ `;
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+
4
+ import { PeriodOfDay } from '@rpg-engine/shared';
5
+ import AfternoonGif from './gif/afternoon.gif';
6
+ import MorningGif from './gif/morning.gif';
7
+ import NightGif from './gif/night.gif';
8
+
9
+ export interface IPeriodOfDayDisplayProps {
10
+ periodOfDay: PeriodOfDay;
11
+ }
12
+
13
+ export const DayNightPeriod: React.FC<IPeriodOfDayDisplayProps> = ({
14
+ periodOfDay,
15
+ }) => {
16
+ const periodOfDaySrcFiles = {
17
+ [PeriodOfDay.Morning]: MorningGif,
18
+ [PeriodOfDay.Afternoon]: AfternoonGif,
19
+ [PeriodOfDay.Night]: NightGif,
20
+ };
21
+
22
+ return (
23
+ <GifContainer>
24
+ <img src={periodOfDaySrcFiles[periodOfDay]} />
25
+ </GifContainer>
26
+ );
27
+ };
28
+
29
+ const GifContainer = styled.span`
30
+ width: 100%;
31
+ `;
@@ -0,0 +1,63 @@
1
+ import { PeriodOfDay } from '@rpg-engine/shared';
2
+ import React from 'react';
3
+ import Draggable from 'react-draggable';
4
+ import styled from 'styled-components';
5
+ import { uiFonts } from '../../constants/uiFonts';
6
+ import { DayNightPeriod } from './DayNightPeriod/DayNightPeriod';
7
+
8
+ import ClockWidgetImg from './img/clockwidget.png';
9
+
10
+ export interface IClockWidgetProps {
11
+ onClose?: () => void;
12
+ TimeClock: string;
13
+ periodOfDay: PeriodOfDay;
14
+ }
15
+
16
+ export const TimeWidget: React.FC<IClockWidgetProps> = ({
17
+ onClose,
18
+ TimeClock,
19
+ periodOfDay,
20
+ }) => {
21
+ return (
22
+ <Draggable>
23
+ <WidgetContainer>
24
+ <CloseButton onClick={onClose}>X</CloseButton>
25
+ <DayNightContainer>
26
+ <DayNightPeriod periodOfDay={periodOfDay} />
27
+ </DayNightContainer>
28
+ <Time>{TimeClock}</Time>
29
+ </WidgetContainer>
30
+ </Draggable>
31
+ );
32
+ };
33
+
34
+ const WidgetContainer = styled.div`
35
+ background-image: url(${ClockWidgetImg});
36
+ background-repeat: no-repeat;
37
+ width: 100%;
38
+ position: absolute;
39
+ margin: 20px;
40
+ `;
41
+
42
+ const Time = styled.div`
43
+ width: 100%;
44
+ top: -6.95rem;
45
+ right: -4.4rem;
46
+ position: relative;
47
+ font-size: 7.5px;
48
+ color: white;
49
+ `;
50
+
51
+ const CloseButton = styled.p`
52
+ width: 100%;
53
+ position: relative;
54
+ top: -1rem;
55
+ right: -6.9rem;
56
+ font-size: ${uiFonts.size.xxsmall} !important;
57
+ z-index: 1;
58
+ `;
59
+ const DayNightContainer = styled.span`
60
+ top: -41px;
61
+ left: -3px;
62
+ position: relative;
63
+ `;
package/src/index.tsx CHANGED
@@ -25,6 +25,7 @@ export * from './components/shared/SpriteFromAtlas';
25
25
  export * from './components/SkillProgressBar';
26
26
  export * from './components/SkillsContainer';
27
27
  export * from './components/TextArea';
28
+ export * from './components/TimeWidget/TimeWidget';
28
29
  export * from './components/TradingMenu/TradingMenu';
29
30
  export * from './components/Truncate';
30
31
  export * from './components/typography/DynamicText';
@@ -0,0 +1,27 @@
1
+ import { PeriodOfDay } from '@rpg-engine/shared';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import React from 'react';
4
+ import { RPGUIRoot } from '../components/RPGUIRoot';
5
+ import {
6
+ DayNightPeriod,
7
+ IPeriodOfDayDisplayProps,
8
+ } from '../components/TimeWidget/DayNightPeriod/DayNightPeriod';
9
+
10
+ const meta: Meta = {
11
+ title: 'Day and Night Period',
12
+ component: DayNightPeriod,
13
+ };
14
+
15
+ export default meta;
16
+
17
+ const Template: Story<IPeriodOfDayDisplayProps> = args => (
18
+ <RPGUIRoot>
19
+ <DayNightPeriod {...args} />
20
+ </RPGUIRoot>
21
+ );
22
+
23
+ export const Default = Template.bind({});
24
+
25
+ Default.args = {
26
+ periodOfDay: PeriodOfDay.Morning,
27
+ };
@@ -0,0 +1,32 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ import React from 'react';
3
+ import { RPGUIRoot } from '..';
4
+ import {
5
+ IStaticBookProps,
6
+ StaticBook,
7
+ } from '../components/StaticBook/StaticBook';
8
+
9
+ const meta: Meta = {
10
+ title: 'Static Book',
11
+ component: StaticBook,
12
+ };
13
+
14
+ export default meta;
15
+
16
+ const Template: Story<IStaticBookProps> = args => (
17
+ <RPGUIRoot>
18
+ <StaticBook
19
+ {...args}
20
+ onClose={() => console.log('Trying to close the book!')}
21
+ />
22
+ </RPGUIRoot>
23
+ );
24
+
25
+ export const Default = Template.bind({});
26
+
27
+ const bookMock =
28
+ 'Computers and RPGs have always gone hand-in-hand. Even when the bes and Oubliette. A few, such as Oubliette, had simple graphics, though most started out as just text or used ASCII’s standard set of text-mode graphics The most successful dungeon crawler of all time is, of course, Blizzard’s Diablo. But Rogue’s longest-lived descendent is arguably a much more interesting game—1987’s Nethack. Technically, it was based on a Rogue clone called, yes, Hack, but let’s not quibble. Nethack takes the basic dungeon crawling concept and adds several decades worth of development. The original PC RPGs—such as MUDs, or multi-user dungeons—appeared in the mid-70s. These weren’t for home computers, but mainframes, typically found in universities. They tended to be based on either Dungeons & Dragons, which itself launched in 1974, or be variously disguised takes on Tolkien. These included Dungeon, DND, Orthanc, and Oubliette. A few, such as Oubliette, had simple graphics, though most started out as just text or used ASCII’s standard set of text-mode graphics The most successful dungeon crawler of all time is, of course, Blizzard’s Diablo. But Rogue’s longest-lived descendent is arguably a much more interesting game—1987’s Nethack. Technically, it was based on a Rogue clone called, yes, Hack, but let’s not quibble. Nethack takes the basic dungeon crawling concept and adds several decades worth of development. Despite the primitive technology, these games often offered surprising depth. Don Daglow’s Dungeon for instance, a 1975 D&D pastiche, offered control of an entire multiplayer party, mapping, NPCs with AI, line-of-sight-based combat, and both melee and ranged attacks. Moria, from the same year, served up wireframe graphics for its characters, and even featured rudimentary 3D views of its corridors. Small ones, with no detail, but let’s not forget that even Space Invaders wasn’t out yet! Ever wondered if throwing a custard pie in a basilisk’s face will stop its petrifying stare? Nethack not only answers that question (it will), but also implements blindness if you get hit by a pie yourself, causes you to break your code if a vegan character eats one (seriously), and ensures the attack doesn’t count if you’re on a pacifist run (it does no damage, no matter your combat bonus). This level of detail lead to the saying “The Dev Team Thinks Of Everything”. Many versions are now available, from the original ASCII-based game to graphical overhauls like Vulture’s Eye. All are free, as a condition of the distribution licence. While the original Rogue was a single-player game, the first multiplayer game was probably 1980’s MUD, or Multi-User Dungeon. This was a text-based game, but with the ability to play with other people. It was also the first game to use the term “multiplayer” in its name. MUDs were hugely popular, and spawned a whole genre of games, including the aforementioned Nethack. The most successful of these was probably 1988’s MUD1, which was so popular that it was ported to the Commodore 64. The most successful of these was probably 1988’s MUD1, which was so popular that it was ported to the Commodore 64. The most successful of these was probably 1988’s MUD1, which was so popular that it was ported to the Commodore 64. The most successful of these was probably 1988’s MUD1, which was so popular that it was ported to the Commodore 64. ';
29
+
30
+ Default.args = {
31
+ content: bookMock,
32
+ };
@@ -0,0 +1,27 @@
1
+ import { PeriodOfDay } from '@rpg-engine/shared';
2
+ import { Meta, Story } from '@storybook/react';
3
+ import React from 'react';
4
+ import { RPGUIRoot } from '../components/RPGUIRoot';
5
+ import {
6
+ IClockWidgetProps,
7
+ TimeWidget,
8
+ } from '../components/TimeWidget/TimeWidget';
9
+
10
+ const meta: Meta = {
11
+ title: 'Time Widget',
12
+ component: TimeWidget,
13
+ };
14
+
15
+ export default meta;
16
+
17
+ const Template: Story<IClockWidgetProps> = args => (
18
+ <RPGUIRoot>
19
+ <TimeWidget {...args} />
20
+ </RPGUIRoot>
21
+ );
22
+
23
+ export const Default = Template.bind({});
24
+ Default.args = {
25
+ TimeClock: '10:00',
26
+ periodOfDay: PeriodOfDay.Morning,
27
+ };