@rpg-engine/long-bow 0.8.52 → 0.8.54
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.
- package/dist/components/DailyTasks/DailyTasks.d.ts +3 -2
- package/dist/long-bow.cjs.development.js +111 -122
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +112 -123
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ConfirmModal.tsx +121 -51
- package/src/components/DailyTasks/DailyTasks.tsx +32 -15
- package/src/components/DailyTasks/GlobalDailyProgress.tsx +5 -2
- package/dist/hooks/useDailyTasksState.d.ts +0 -13
- package/src/hooks/useDailyTasksState.ts +0 -40
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
2
|
+
import styled, { createGlobalStyle } from 'styled-components';
|
|
3
3
|
import ModalPortal from './Abstractions/ModalPortal';
|
|
4
4
|
import { Button, ButtonTypes } from './Button';
|
|
5
|
-
import { DraggableContainer } from './DraggableContainer';
|
|
6
5
|
|
|
7
6
|
export interface IConfirmModalProps {
|
|
8
7
|
onConfirm: () => void;
|
|
@@ -10,90 +9,161 @@ export interface IConfirmModalProps {
|
|
|
10
9
|
message?: string | ReactNode;
|
|
11
10
|
}
|
|
12
11
|
|
|
12
|
+
// Global style to prevent body scrolling when modal is open
|
|
13
|
+
const GlobalStyle = createGlobalStyle`
|
|
14
|
+
body {
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
13
22
|
export const ConfirmModal: React.FC<IConfirmModalProps> = ({
|
|
14
23
|
onConfirm,
|
|
15
24
|
onClose,
|
|
16
25
|
message = 'Are you sure?',
|
|
17
26
|
}) => {
|
|
18
|
-
const handleConfirm = (
|
|
19
|
-
e.preventDefault();
|
|
20
|
-
e.stopPropagation();
|
|
27
|
+
const handleConfirm = () => {
|
|
21
28
|
onConfirm();
|
|
22
29
|
};
|
|
23
30
|
|
|
24
|
-
const handleClose = (
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
e.stopPropagation();
|
|
31
|
+
const handleClose = () => {
|
|
27
32
|
onClose();
|
|
28
33
|
};
|
|
29
34
|
|
|
35
|
+
const stopPropagation = (e: React.PointerEvent) => {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
};
|
|
38
|
+
|
|
30
39
|
return (
|
|
31
40
|
<ModalPortal>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
41
|
+
<GlobalStyle />
|
|
42
|
+
<Overlay onPointerDown={handleClose} />
|
|
43
|
+
<ModalContainer>
|
|
44
|
+
<ModalContent onPointerDown={stopPropagation}>
|
|
45
|
+
<MessageContainer>
|
|
46
|
+
{typeof message === 'string' ? (
|
|
47
|
+
<Message>{message}</Message>
|
|
48
|
+
) : (
|
|
49
|
+
message
|
|
50
|
+
)}
|
|
51
|
+
</MessageContainer>
|
|
52
|
+
|
|
53
|
+
<ButtonsContainer>
|
|
54
|
+
<CancelButtonWrapper>
|
|
47
55
|
<Button
|
|
48
56
|
buttonType={ButtonTypes.RPGUIButton}
|
|
49
|
-
|
|
57
|
+
onPointerDown={handleClose}
|
|
50
58
|
>
|
|
51
|
-
|
|
59
|
+
No
|
|
52
60
|
</Button>
|
|
53
|
-
</
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
</CancelButtonWrapper>
|
|
62
|
+
<Button
|
|
63
|
+
buttonType={ButtonTypes.RPGUIButton}
|
|
64
|
+
onPointerDown={handleConfirm}
|
|
65
|
+
>
|
|
66
|
+
Yes
|
|
67
|
+
</Button>
|
|
68
|
+
</ButtonsContainer>
|
|
69
|
+
</ModalContent>
|
|
70
|
+
</ModalContainer>
|
|
57
71
|
</ModalPortal>
|
|
58
72
|
);
|
|
59
73
|
};
|
|
60
74
|
|
|
61
|
-
const
|
|
62
|
-
position:
|
|
63
|
-
width: 100%;
|
|
64
|
-
height: 100%;
|
|
65
|
-
background-color: #000000;
|
|
66
|
-
opacity: 0.5;
|
|
67
|
-
left: 0;
|
|
75
|
+
const Overlay = styled.div`
|
|
76
|
+
position: fixed;
|
|
68
77
|
top: 0;
|
|
78
|
+
left: 0;
|
|
79
|
+
right: 0;
|
|
80
|
+
bottom: 0;
|
|
81
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
69
82
|
z-index: 1000;
|
|
83
|
+
animation: fadeIn 0.2s ease-out;
|
|
84
|
+
|
|
85
|
+
@keyframes fadeIn {
|
|
86
|
+
from {
|
|
87
|
+
opacity: 0;
|
|
88
|
+
}
|
|
89
|
+
to {
|
|
90
|
+
opacity: 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
70
93
|
`;
|
|
71
94
|
|
|
72
|
-
const
|
|
73
|
-
position:
|
|
74
|
-
width: 100%;
|
|
75
|
-
height: 100%;
|
|
76
|
-
left: 0;
|
|
95
|
+
const ModalContainer = styled.div`
|
|
96
|
+
position: fixed;
|
|
77
97
|
top: 0;
|
|
98
|
+
left: 0;
|
|
99
|
+
right: 0;
|
|
100
|
+
bottom: 0;
|
|
78
101
|
display: flex;
|
|
79
|
-
justify-content: center;
|
|
80
102
|
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
81
104
|
z-index: 1001;
|
|
105
|
+
padding: env(safe-area-inset-top) env(safe-area-inset-right)
|
|
106
|
+
env(safe-area-inset-bottom) env(safe-area-inset-left);
|
|
107
|
+
touch-action: none;
|
|
108
|
+
`;
|
|
109
|
+
|
|
110
|
+
const ModalContent = styled.div`
|
|
111
|
+
background: url('/assets/ui/paper-dialog.png') no-repeat center center;
|
|
112
|
+
background-size: 100% 100%;
|
|
113
|
+
padding: 20px;
|
|
114
|
+
min-width: 300px;
|
|
115
|
+
max-width: 90%;
|
|
116
|
+
margin: 0 auto;
|
|
117
|
+
animation: scaleIn 0.2s ease-out;
|
|
118
|
+
transform-origin: center;
|
|
119
|
+
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
|
|
120
|
+
|
|
121
|
+
@keyframes scaleIn {
|
|
122
|
+
from {
|
|
123
|
+
transform: scale(0.8);
|
|
124
|
+
opacity: 0;
|
|
125
|
+
}
|
|
126
|
+
to {
|
|
127
|
+
transform: scale(1);
|
|
128
|
+
opacity: 1;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@media (max-width: 768px) {
|
|
133
|
+
padding: 25px;
|
|
134
|
+
width: 85%;
|
|
135
|
+
}
|
|
136
|
+
`;
|
|
137
|
+
|
|
138
|
+
const MessageContainer = styled.div`
|
|
139
|
+
margin-bottom: 20px;
|
|
140
|
+
text-align: center;
|
|
82
141
|
`;
|
|
83
142
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
143
|
+
const Message = styled.p`
|
|
144
|
+
margin: 0;
|
|
145
|
+
font-size: 16px;
|
|
146
|
+
color: #333;
|
|
147
|
+
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
|
148
|
+
|
|
149
|
+
@media (max-width: 768px) {
|
|
150
|
+
font-size: 18px;
|
|
87
151
|
}
|
|
88
152
|
`;
|
|
89
153
|
|
|
90
|
-
const
|
|
154
|
+
const ButtonsContainer = styled.div`
|
|
91
155
|
display: flex;
|
|
92
|
-
justify-content:
|
|
93
|
-
gap:
|
|
94
|
-
margin-top: 5px;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
gap: 20px;
|
|
95
158
|
|
|
96
|
-
|
|
97
|
-
|
|
159
|
+
@media (max-width: 768px) {
|
|
160
|
+
gap: 30px;
|
|
161
|
+
/* Increase button size for better touch targets */
|
|
162
|
+
transform: scale(1.1);
|
|
163
|
+
margin-top: 5px;
|
|
98
164
|
}
|
|
99
165
|
`;
|
|
166
|
+
|
|
167
|
+
const CancelButtonWrapper = styled.div`
|
|
168
|
+
filter: grayscale(0.7);
|
|
169
|
+
`;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ICharacterDailyTask,
|
|
3
3
|
ICollectGlobalRewardRequest,
|
|
4
|
-
|
|
4
|
+
ICollectRewardRequest,
|
|
5
|
+
TaskType,
|
|
5
6
|
} from '@rpg-engine/shared';
|
|
6
|
-
import React from 'react';
|
|
7
|
+
import React, { useState } from 'react';
|
|
7
8
|
import styled from 'styled-components';
|
|
8
9
|
import { uiColors } from '../../constants/uiColors';
|
|
9
|
-
import { useDailyTasksState } from '../../hooks/useDailyTasksState';
|
|
10
10
|
import { useResponsiveSize } from '../CraftBook/hooks/useResponsiveSize';
|
|
11
11
|
import { DraggableContainer } from '../DraggableContainer';
|
|
12
12
|
import { RPGUIContainerTypes } from '../RPGUI/RPGUIContainer';
|
|
@@ -16,7 +16,7 @@ import { getTaskIcon } from './utils/dailyTasks.utils';
|
|
|
16
16
|
|
|
17
17
|
export interface IDailyTasksProps {
|
|
18
18
|
tasks: ICharacterDailyTask[];
|
|
19
|
-
onClaimReward: (task:
|
|
19
|
+
onClaimReward: (task: ICollectRewardRequest) => void;
|
|
20
20
|
onClaimGlobalReward: (tasks: ICollectGlobalRewardRequest) => void;
|
|
21
21
|
onClose: () => void;
|
|
22
22
|
scale?: number;
|
|
@@ -24,6 +24,7 @@ export interface IDailyTasksProps {
|
|
|
24
24
|
itemsAtlasIMG: string;
|
|
25
25
|
iconAtlasJSON?: Record<string, any>;
|
|
26
26
|
iconAtlasIMG?: string;
|
|
27
|
+
globalRewardClaimed?: boolean;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export const DailyTasks: React.FC<IDailyTasksProps> = ({
|
|
@@ -36,19 +37,31 @@ export const DailyTasks: React.FC<IDailyTasksProps> = ({
|
|
|
36
37
|
itemsAtlasIMG,
|
|
37
38
|
iconAtlasJSON,
|
|
38
39
|
iconAtlasIMG,
|
|
40
|
+
globalRewardClaimed = false,
|
|
39
41
|
}): JSX.Element | null => {
|
|
40
42
|
const [localTasks] = React.useState(tasks);
|
|
41
43
|
const size = useResponsiveSize(scale);
|
|
44
|
+
const [claimedTasks, setClaimedTasks] = useState<string[]>([]);
|
|
45
|
+
const [globalRewardClaimedLocal, setGlobalRewardClaimedLocal] = useState(
|
|
46
|
+
false
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const handleClaimReward = (taskKey: string, taskType: TaskType) => {
|
|
50
|
+
onClaimReward({
|
|
51
|
+
taskKey,
|
|
52
|
+
type: taskType,
|
|
53
|
+
});
|
|
54
|
+
setClaimedTasks(prev => [...prev, taskKey]);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const handleClaimGlobalRewards = (tasks: ICollectGlobalRewardRequest) => {
|
|
58
|
+
onClaimGlobalReward(tasks);
|
|
59
|
+
setGlobalRewardClaimedLocal(true);
|
|
60
|
+
};
|
|
42
61
|
|
|
43
|
-
const {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
handleClaimGlobalRewards,
|
|
47
|
-
isTaskRewardClaimed,
|
|
48
|
-
} = useDailyTasksState({
|
|
49
|
-
onClaimReward,
|
|
50
|
-
onClaimGlobalReward,
|
|
51
|
-
});
|
|
62
|
+
const isTaskRewardClaimed = (taskKey: string): boolean => {
|
|
63
|
+
return claimedTasks.includes(taskKey);
|
|
64
|
+
};
|
|
52
65
|
|
|
53
66
|
if (!size) return null;
|
|
54
67
|
|
|
@@ -67,7 +80,9 @@ export const DailyTasks: React.FC<IDailyTasksProps> = ({
|
|
|
67
80
|
<GlobalDailyProgress
|
|
68
81
|
tasks={localTasks}
|
|
69
82
|
onClaimAllRewards={handleClaimGlobalRewards}
|
|
70
|
-
globalRewardClaimed={
|
|
83
|
+
globalRewardClaimed={
|
|
84
|
+
globalRewardClaimed || globalRewardClaimedLocal
|
|
85
|
+
}
|
|
71
86
|
/>
|
|
72
87
|
{localTasks.map(task => (
|
|
73
88
|
<DailyTaskItem
|
|
@@ -79,7 +94,7 @@ export const DailyTasks: React.FC<IDailyTasksProps> = ({
|
|
|
79
94
|
itemsAtlasIMG={itemsAtlasIMG}
|
|
80
95
|
iconAtlasJSON={iconAtlasJSON}
|
|
81
96
|
iconAtlasIMG={iconAtlasIMG}
|
|
82
|
-
isRewardClaimed={isTaskRewardClaimed(task.key)}
|
|
97
|
+
isRewardClaimed={task.claimed || isTaskRewardClaimed(task.key)}
|
|
83
98
|
/>
|
|
84
99
|
))}
|
|
85
100
|
</TasksList>
|
|
@@ -145,3 +160,5 @@ const TaskTitle = styled.h2`
|
|
|
145
160
|
font-size: 1.4rem !important;
|
|
146
161
|
width: 100%;
|
|
147
162
|
`;
|
|
163
|
+
|
|
164
|
+
|
|
@@ -34,6 +34,8 @@ export const GlobalDailyProgress: React.FC<IGlobalTaskProgressProps> = ({
|
|
|
34
34
|
const shouldShowGlobalButton =
|
|
35
35
|
allCompleted && allClaimed && !globalRewardClaimed;
|
|
36
36
|
|
|
37
|
+
const shouldShowClaimedMessage = globalRewardClaimed;
|
|
38
|
+
|
|
37
39
|
const handleClaimAll = () => {
|
|
38
40
|
const taskIdentifiers = tasks.map(task => ({
|
|
39
41
|
taskKey: task.key,
|
|
@@ -55,7 +57,7 @@ export const GlobalDailyProgress: React.FC<IGlobalTaskProgressProps> = ({
|
|
|
55
57
|
</ProgressBar>
|
|
56
58
|
{allCompleted && (
|
|
57
59
|
<>
|
|
58
|
-
{shouldShowGlobalButton
|
|
60
|
+
{shouldShowGlobalButton && (
|
|
59
61
|
<CollectWrapper>
|
|
60
62
|
<Button
|
|
61
63
|
buttonType={ButtonTypes.RPGUIButton}
|
|
@@ -64,7 +66,8 @@ export const GlobalDailyProgress: React.FC<IGlobalTaskProgressProps> = ({
|
|
|
64
66
|
Collect Global Rewards
|
|
65
67
|
</Button>
|
|
66
68
|
</CollectWrapper>
|
|
67
|
-
)
|
|
69
|
+
)}
|
|
70
|
+
{shouldShowClaimedMessage && (
|
|
68
71
|
<ClaimedText>Global Rewards Claimed</ClaimedText>
|
|
69
72
|
)}
|
|
70
73
|
</>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ICollectGlobalRewardRequest, ITaskIdentifier, TaskType } from '@rpg-engine/shared';
|
|
2
|
-
interface IUseDailyTasksStateProps {
|
|
3
|
-
onClaimReward: (task: ITaskIdentifier) => void;
|
|
4
|
-
onClaimGlobalReward: (tasks: ICollectGlobalRewardRequest) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function useDailyTasksState({ onClaimReward, onClaimGlobalReward, }: IUseDailyTasksStateProps): {
|
|
7
|
-
globalRewardClaimed: boolean;
|
|
8
|
-
claimedTaskKeys: string[];
|
|
9
|
-
isTaskRewardClaimed: (taskKey: string) => boolean;
|
|
10
|
-
handleClaimReward: (taskKey: string, type: TaskType) => void;
|
|
11
|
-
handleClaimGlobalRewards: (tasks: ICollectGlobalRewardRequest) => void;
|
|
12
|
-
};
|
|
13
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { ICollectGlobalRewardRequest, ITaskIdentifier, TaskType } from '@rpg-engine/shared';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
|
|
4
|
-
interface IUseDailyTasksStateProps {
|
|
5
|
-
onClaimReward: (task: ITaskIdentifier) => void;
|
|
6
|
-
onClaimGlobalReward: (tasks: ICollectGlobalRewardRequest) => void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function useDailyTasksState({
|
|
10
|
-
onClaimReward,
|
|
11
|
-
onClaimGlobalReward,
|
|
12
|
-
}: IUseDailyTasksStateProps) {
|
|
13
|
-
const [globalRewardClaimed, setGlobalRewardClaimed] = useState(false);
|
|
14
|
-
const [claimedTaskKeys, setClaimedTaskKeys] = useState<string[]>([]);
|
|
15
|
-
|
|
16
|
-
const handleClaimReward = (taskKey: string, type: TaskType) => {
|
|
17
|
-
onClaimReward({
|
|
18
|
-
type,
|
|
19
|
-
taskKey,
|
|
20
|
-
});
|
|
21
|
-
setClaimedTaskKeys(prev => [...prev, taskKey]);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const handleClaimGlobalRewards = (tasks: ICollectGlobalRewardRequest) => {
|
|
25
|
-
onClaimGlobalReward(tasks);
|
|
26
|
-
setGlobalRewardClaimed(true);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const isTaskRewardClaimed = (taskKey: string): boolean => {
|
|
30
|
-
return claimedTaskKeys.includes(taskKey);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
globalRewardClaimed,
|
|
35
|
-
claimedTaskKeys,
|
|
36
|
-
isTaskRewardClaimed,
|
|
37
|
-
handleClaimReward,
|
|
38
|
-
handleClaimGlobalRewards,
|
|
39
|
-
};
|
|
40
|
-
}
|