mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 01:22:54 +00:00
Merge remote-tracking branch 'origin/unstable' into unstable
This commit is contained in:
commit
63488f826a
@ -12,8 +12,7 @@ function invalid(value: number): boolean {
|
|||||||
*/
|
*/
|
||||||
function basicGive(item: number, amount = 1): string {
|
function basicGive(item: number, amount = 1): string {
|
||||||
// Validate the numbers.
|
// Validate the numbers.
|
||||||
if (invalid(item) || invalid(amount))
|
if (invalid(item) || invalid(amount)) return "Invalid arguments.";
|
||||||
return "Invalid arguments.";
|
|
||||||
|
|
||||||
return `/give ${item} x${amount}`;
|
return `/give ${item} x${amount}`;
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,7 @@ class TextState extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return this.state.state ?
|
return this.state.state ? this.props.text2 : this.props.text1;
|
||||||
this.props.text2 :
|
|
||||||
this.props.text1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,15 +86,12 @@ class ItemCard extends React.Component<IProps, IState> {
|
|||||||
*/
|
*/
|
||||||
private async addToInventory(): Promise<void> {
|
private async addToInventory(): Promise<void> {
|
||||||
const item = this.props.item?.id ?? 102;
|
const item = this.props.item?.id ?? 102;
|
||||||
const amount = typeof this.state.count == "string" ?
|
const amount = typeof this.state.count == "string" ? parseInt(this.state.count) : this.state.count;
|
||||||
parseInt(this.state.count) :
|
|
||||||
this.state.count;
|
|
||||||
|
|
||||||
if (connected) {
|
if (connected) {
|
||||||
await giveItem(item, amount);
|
await giveItem(item, amount);
|
||||||
} else {
|
} else {
|
||||||
await copyToClipboard(
|
await copyToClipboard(give.basic(item, amount));
|
||||||
give.basic(item, amount));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,14 +162,8 @@ class ItemCard extends React.Component<IProps, IState> {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button className={"ItemCard_Submit"}
|
<button className={"ItemCard_Submit"} onClick={this.addToInventory.bind(this)}>
|
||||||
onClick={this.addToInventory.bind(this)}
|
<TextState event={"connected"} text1={"Copy Command"} text2={"Add to Inventory"} />
|
||||||
>
|
|
||||||
<TextState
|
|
||||||
event={"connected"}
|
|
||||||
text1={"Copy Command"}
|
|
||||||
text2={"Add to Inventory"}
|
|
||||||
/>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user