@rpg-engine/long-bow 0.2.54 → 0.2.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.2.54",
3
+ "version": "0.2.56",
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.82",
86
+ "@rpg-engine/shared": "^0.5.88",
87
87
  "dayjs": "^1.11.2",
88
88
  "fs-extra": "^10.1.0",
89
89
  "lodash": "^4.17.21",
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
+ import styled from 'styled-components';
2
3
  import { v4 as uuidv4 } from 'uuid';
3
- import { _RPGUI } from './RPGUIRoot';
4
4
 
5
5
  export interface IOptionsProps {
6
6
  id: number;
@@ -22,16 +22,17 @@ export const Dropdown: React.FC<IDropdownProps> = ({
22
22
  const dropdownId = uuidv4();
23
23
 
24
24
  const [selectedValue, setSelectedValue] = useState<string>('');
25
+ const [selectedOption, setSelectedOption] = useState<string>('');
26
+ const [opened, setOpened] = useState<boolean>(false);
25
27
 
26
28
  useEffect(() => {
27
- const element = document.getElementById(`rpgui-dropdown-${dropdownId}`);
28
- const dropdownValue = _RPGUI.get_value(element);
29
- setSelectedValue(dropdownValue);
29
+ const firstOption = options[0];
30
30
 
31
- element?.addEventListener('change', (event: any) => {
32
- setSelectedValue(event?.target.value);
33
- });
34
- }, []);
31
+ if (firstOption) {
32
+ setSelectedValue(firstOption.value);
33
+ setSelectedOption(firstOption.option);
34
+ }
35
+ }, [options]);
35
36
 
36
37
  useEffect(() => {
37
38
  if (selectedValue) {
@@ -40,18 +41,50 @@ export const Dropdown: React.FC<IDropdownProps> = ({
40
41
  }, [selectedValue]);
41
42
 
42
43
  return (
43
- <select
44
- id={`rpgui-dropdown-${dropdownId}`}
45
- style={{ width: width }}
46
- className="rpgui-dropdown"
47
- >
48
- {options.map(option => {
49
- return (
50
- <option key={option.id} value={option.value}>
51
- {option.option}
52
- </option>
53
- );
54
- })}
55
- </select>
44
+ <Container onMouseLeave={() => setOpened(false)} width={width}>
45
+ <DropdownSelect
46
+ id={`dropdown-${dropdownId}`}
47
+ className="rpgui-dropdown-imp rpgui-dropdown-imp-header"
48
+ onClick={() => setOpened(prev => !prev)}
49
+ >
50
+ <label>▼</label> {selectedOption}
51
+ </DropdownSelect>
52
+
53
+ <DropdownOptions className="rpgui-dropdown-imp" opened={opened}>
54
+ {options.map(option => {
55
+ return (
56
+ <li
57
+ key={option.id}
58
+ onClick={() => {
59
+ setSelectedValue(option.value);
60
+ setSelectedOption(option.option);
61
+ setOpened(false);
62
+ }}
63
+ >
64
+ {option.option}
65
+ </li>
66
+ );
67
+ })}
68
+ </DropdownOptions>
69
+ </Container>
56
70
  );
57
71
  };
72
+
73
+ const Container = styled.div<{ width: string | undefined }>`
74
+ position: relative;
75
+ width: ${props => props.width || '100%'};
76
+ `;
77
+
78
+ const DropdownSelect = styled.p`
79
+ width: 100%;
80
+ box-sizing: border-box;
81
+ `;
82
+
83
+ const DropdownOptions = styled.ul<{
84
+ opened: boolean;
85
+ }>`
86
+ position: absolute;
87
+ width: 100%;
88
+ display: ${props => (props.opened ? 'block' : 'none')};
89
+ box-sizing: border-box;
90
+ `;
@@ -49,9 +49,9 @@ export const generateContextMenu = (
49
49
  ActionsForInventory.Consumable
50
50
  );
51
51
  break;
52
- case ItemType.CraftMaterial:
52
+ case ItemType.CraftingResource:
53
53
  contextActionMenu = generateContextMenuListOptions(
54
- ActionsForInventory.CraftMaterial
54
+ ActionsForInventory.CraftingResource
55
55
  );
56
56
  break;
57
57
  case ItemType.Tool:
@@ -96,9 +96,9 @@ export const generateContextMenu = (
96
96
  ActionsForLoot.Consumable
97
97
  );
98
98
  break;
99
- case ItemType.CraftMaterial:
99
+ case ItemType.CraftingResource:
100
100
  contextActionMenu = generateContextMenuListOptions(
101
- ActionsForLoot.CraftMaterial
101
+ ActionsForLoot.CraftingResource
102
102
  );
103
103
  break;
104
104
  case ItemType.Tool:
@@ -126,9 +126,9 @@ export const generateContextMenu = (
126
126
  ActionsForMapContainer.Consumable
127
127
  );
128
128
  break;
129
- case ItemType.CraftMaterial:
129
+ case ItemType.CraftingResource:
130
130
  contextActionMenu = generateContextMenuListOptions(
131
- ActionsForMapContainer.CraftMaterial
131
+ ActionsForMapContainer.CraftingResource
132
132
  );
133
133
  break;
134
134
  case ItemType.Tool:
@@ -42,7 +42,7 @@ const skillProps = {
42
42
  values: {
43
43
  fishing: 'foods/fish.png',
44
44
  mining: 'crafting-resources/iron-ingot.png',
45
- lumberjacking: 'crafting-resources/greater-wood-log.png',
45
+ lumberjacking: 'crafting-resources/greater-wooden-log.png',
46
46
  cooking: 'foods/chickens-meat.png',
47
47
  alchemy: 'potions/greater-mana-potion.png',
48
48
  },