Open kendallroth opened 4 months ago
Took a shot at this last night but wasn't satisfied... Need to find a good way of only triggering this if no other conflicting tools/panels are open. Would be ideal to also find a way to open the infoview menu and associated infoview panel, and not keep toggling the infoview menu (no "set" method; only "toggle") 😢.
const infoviewList = useValue(infoview.infoviews$);
const activeTool = useValue(tool.activeTool$);
const activeInfoview = useValue(infoview.activeInfoview$);
const defaultToolActive = activeTool.id === tool.DEFAULT_TOOL;
const handleStatClick = (stat: StatsPanelItem) => {
// Avoid opening info panel if another tool is already open (would be confusing)
// TODO: Consider removing this???
if (!defaultToolActive) return;
const infoView = infoviewList.find((i) => i.id === stat.infoviewId);
if (!infoView) return;
// logger.log(infoView);
// logger.log(activeTool, defaultToolActive);
// logger.log(activeInfoview);
// TODO: Only toggle infoview menu if not already open
if (!activeInfoview) {
// game.toggleInfoviewMenu();
}
// NOTE: Currently does not open infoview menu but just the active overlay, which can lead to some odd visual glitches if selecting
// something in the game that closes overlay but keeps color applied
// infoview.setActiveInfoview(infoView.entity);
};
Clicking on an icon should open the corresponding info view (see forum post for original request). It may be beneficial to only open if no other tool is selected (other than default empty tool), although this could maybe be a setting?
The
bindings.d.ts
file suggests that this might be possible using a combination of the JS bindings.