SHARE
TWEET

Untitled

a guest Dec 10th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { Button } from 'react-bootstrap';
  3. import { Tooltip } from 'react-bootstrap';
  4. import "./SelectedIngredient.scss";
  5.  
  6. export default class SelectedIngredient extends Component {
  7.     constructor(props) {
  8.         super(props);
  9.         this.getIngredientImage = this.getIngredientImage.bind(this);
  10.         this.getSlotImage = this.getSlotImage.bind(this);
  11.         this.onMouseDown = this.onMouseDown.bind(this)
  12.         this.state = {
  13.             rotate: false
  14.         }
  15.  
  16.     }
  17.     handleDrop(index, event) {
  18.         // this.props.onDragEndSelectedIngredientCallback();
  19.         // callback(index);
  20.     }
  21.     rotateFunction() {
  22.         this.setState({ rotate: true });
  23.  
  24.     }
  25.     onMouseDown() {
  26.         this.props.onMouseDown();
  27.     }
  28.     getIngredientImage() {
  29.         if (this.props.selected_ingredient != null) {
  30.             //if (!this.state.rotate ){
  31.             return <div onMouseDown={this.onMouseDown.bind(this)}> <img className="top-img"  draggable="false" src={"/images/" + (this.props.selected_ingredient.category == "glasses" ? "glasses/" : "ingredients/") + this.props.selected_ingredient.name + ".png"} alt={"Missing Image: " + this.props.selected_ingredient.name} /> </div>
  32.             // }
  33.             /*else {
  34.             return <div> <img  className="rotImg" onClick={this.rotateFunction.bind(this)} draggable="false" src={"/images/" + (this.props.selected_ingredient.category == "glasses" ? "glasses/" : "ingredients/") + this.props.selected_ingredient.name + ".png"} alt={"Missing Image: " + this.props.selected_ingredient.name} /> </div>
  35.  
  36.             }*/
  37.             {/* <span className="tooltiptext" >
  38.                     {this.props.inventory[index].actionStack.map((item) => {
  39.                         return (<p key={item.name}>{item.name}</p>);
  40.                     })}
  41.                 </span> */}
  42.  
  43.         } else {
  44.             return <div id="tooltip" onMouseDown={this.onMouseDown.bind(this)}>
  45.                 <img className="bottom-img" src="/images/actions/empty_spot.png" alt="empty spot" />
  46.                 <span className="tooltiptext">There's nothing in this space!</span>
  47.             </div>
  48.         }
  49.     }
  50.     getSlotImage() {
  51.  
  52.         if (this.props.selected_bar != null) {
  53.             if (this.props.selected_bar.bar == "quick") {
  54.                 var glass = this.props.selected_bar.data.glass;
  55.                 var actionBar = this.props.selected_bar.data.actionStack;
  56.                 var callback = this.props.renderGlass;
  57.                 return callback(glass, actionBar);
  58.             } else if (this.props.selected_bar.bar == "action") {
  59.                 var slot = this.props.selected_bar.slot
  60.                 return this.props.renderActionBarItem(slot)
  61.             }
  62.  
  63.         } else {
  64.             return <div id="tooltip">
  65.                 <img className="bottom-img" src="/images/actions/empty_spot.png" alt="empty spot" />
  66.                 <span className="tooltiptext">There's nothing in this space!</span>
  67.             </div>
  68.         }
  69.     }
  70.     render() {
  71.         return (
  72.             <div className="selected_ingredient">
  73.                 <div onDrop={this.handleDrop.bind(this, 0)} onDragOver={(e) => e.preventDefault()} draggable>
  74.                     {
  75.                         this.getIngredientImage()
  76.                     }
  77.                 </div>
  78.                 <div className="selected-slot" onDrop={this.handleDrop.bind(this, 1)} onDragOver={(e) => e.preventDefault()} draggable>
  79.                     {
  80.                         this.getSlotImage()
  81.                     }
  82.                 </div>
  83.             </div>
  84.         );
  85.     }
  86.  
  87. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top