-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first draft * simplify plot planner position and add positions for all areas * add layer control + rename for consistency * show only plannable slimes in planner * adding icons + making planner work for other plottypes * WIP write plan to local storage and read plan from local storage * WIP write plan to local storage and read plan from local storage * fixing bugs, adding tooltip for user pins and adding plot planner info in sidebar * code clean up * code format * make popup look nicer * make tooltip look a bit nicer * linting --------- Co-authored-by: Brook J <[email protected]>
- Loading branch information
1 parent
07d9464
commit 1355265
Showing
36 changed files
with
945 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
import L from "leaflet"; | ||
|
||
import { LocalStoragePlotPlan, Pin, PlannerIcons, PlotOptions } from "../../types"; | ||
import { icon_template } from "../../globals"; | ||
|
||
enum Side { | ||
left, | ||
right, | ||
} | ||
|
||
export default function Planner({ | ||
plotType, | ||
icons, | ||
setIcons, | ||
plotPlan, | ||
setPlotPlan, | ||
}: { | ||
plotType: PlotOptions; | ||
icons: PlannerIcons; | ||
setIcons: React.Dispatch<React.SetStateAction<PlannerIcons>>; | ||
plotPlan: LocalStoragePlotPlan; | ||
setPlotPlan: (a: LocalStoragePlotPlan) => void; | ||
}) { | ||
function onChange(eventValue: number, side: Side, options: Pin[]) { | ||
const val = options[eventValue]; | ||
|
||
if (side === Side.left) { | ||
setIcons({ | ||
...icons, | ||
left: | ||
val !== undefined | ||
? { | ||
name: val.name, | ||
icon: L.icon({ | ||
...icon_template, | ||
iconUrl: val.icon, | ||
}), | ||
} | ||
: icons.right === null | ||
? { | ||
name: plotType.name, | ||
icon: L.icon({ | ||
...icon_template, | ||
iconUrl: plotType.icon, | ||
}), | ||
} | ||
: null, | ||
}); | ||
|
||
setPlotPlan({ ...plotPlan, selectedOptionA: eventValue }); | ||
} else { | ||
setIcons({ | ||
left: | ||
val !== undefined | ||
? icons.left !== null && icons.left.icon.options.iconUrl.includes("plots") | ||
? null | ||
: icons.left | ||
: { | ||
name: plotType.name, | ||
icon: L.icon({ | ||
...icon_template, | ||
iconUrl: plotType.icon, | ||
}), | ||
}, | ||
right: | ||
val !== undefined | ||
? { | ||
name: val.name, | ||
icon: L.icon({ | ||
...icon_template, | ||
iconUrl: val.icon, | ||
}), | ||
} | ||
: null, | ||
}); | ||
setPlotPlan({ ...plotPlan, selectedOptionB: eventValue }); | ||
} | ||
} | ||
|
||
return ( | ||
<div className="flex justify-between gap-5"> | ||
{(plotType?.optionsA || plotType?.optionsB) ? ( | ||
<div className="flex flex-col gap-2"> | ||
{plotType?.optionsA ? ( | ||
plotType.optionsA.length === 1 ? ( | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="ml-2 text-lg">Slime?</h2> | ||
<div className="flex flex-row gap-1"> | ||
<input | ||
type="checkbox" | ||
checked={plotPlan.selectedOptionA === 0} | ||
onChange={(e) => | ||
e.target.checked | ||
? onChange(0, Side.left, plotType.optionsA) | ||
: onChange(-1, Side.left, plotType.optionsA) | ||
} | ||
name={plotType.optionsA[0].name} | ||
/> | ||
<label className="ml-2">{plotType.optionsAName}</label> | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="ml-2 text-lg">{plotType.optionsAName}</h2> | ||
<select | ||
onChange={(e) => onChange(e.target.value, Side.left, plotType.optionsA)} | ||
className="bg-transparent outline outline-1 p-1" | ||
value={plotPlan.selectedOptionA ? plotPlan.selectedOptionA : "Empty"} | ||
> | ||
<option>Empty</option> | ||
{plotType.optionsA.map((resource, index) => ( | ||
<option key={index} value={index}> | ||
{resource.name} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
) | ||
) : ( | ||
<></> | ||
)} | ||
|
||
{plotType?.optionsB ? ( | ||
plotType.optionsB.length === 1 ? ( | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="ml-2 text-lg">Slime?</h2> | ||
<div className="flex flex-row gap-1"> | ||
<input | ||
type="checkbox" | ||
checked={plotPlan.selectedOptionB === 0} | ||
onChange={(e) => | ||
e.target.checked | ||
? onChange(0, Side.right, plotType.optionsB) | ||
: onChange(-1, Side.right, plotType.optionsB) | ||
} | ||
name={plotType.optionsB[0].name} | ||
/> | ||
<label className="ml-2">{plotType.optionsBName}</label> | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="ml-2 text-lg">{plotType.optionsBName}</h2> | ||
<select | ||
onChange={(e) => onChange(e.target.value, Side.right, plotType.optionsB)} | ||
className="bg-transparent outline outline-1 p-1" | ||
value={plotPlan.selectedOptionB ? plotPlan.selectedOptionB : "Empty"} | ||
> | ||
<option>Empty</option> | ||
{plotType.optionsB.map((resource, index) => ( | ||
<option key={index} value={index}> | ||
{resource.name} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
) | ||
) : ( | ||
<></> | ||
)} | ||
</div>) : (<></>)} | ||
|
||
{plotType?.upgrades.length > 0 ? ( | ||
<div className="flex flex-col gap-1"> | ||
<h2 className="ml-2 text-lg">Upgrades</h2> | ||
{plotType.upgrades.map((additionalOption, index) => ( | ||
<div key={index}> | ||
<input | ||
type="checkbox" | ||
checked={plotPlan.selectedUpgrades.includes(index)} | ||
onChange={(e) => { | ||
let upgrades; | ||
e.target.checked | ||
? (upgrades = [...plotPlan.selectedUpgrades, index]) | ||
: (upgrades = plotPlan.selectedUpgrades.filter((value) => value !== index)); | ||
setPlotPlan({ ...plotPlan, selectedUpgrades: upgrades }); | ||
}} | ||
name={additionalOption} | ||
/> | ||
<label className="ml-2">{additionalOption}</label> | ||
</div> | ||
))} | ||
</div> | ||
) : ( | ||
<></> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.