Set up contributor and detail scene

This commit is contained in:
Dennis Schoepf 2021-07-24 17:19:54 +02:00
parent 18850e9fb8
commit e6536ca7c8
8 changed files with 73 additions and 3 deletions

3
.htmlnanorc.js Normal file
View file

@ -0,0 +1,3 @@
module.exports = {
minifySvg: false,
};

View file

@ -4,7 +4,11 @@
"name": "block", "name": "block",
"path": "packages/block", "path": "packages/block",
"size": 2450, "size": 2450,
"contents": {} "contents": {
"legacy": ["Test"],
"contributors": ["Test"],
"packages": ["Test"]
}
}, },
{ {
"name": "client", "name": "client",

View file

@ -64,3 +64,7 @@ export function generateEdges(subprojects: SubProject[]): Edge[] {
}) })
); );
} }
export function getSubproject(name: string, projects: SubProject[]): SubProject {
return projects.filter((project) => project.name === name)[0];
}

View file

@ -1,19 +1,31 @@
import { mp5 } from '../../main'; import { mp5 } from '../../main';
import { colors } from '../constants/colors';
import { Player } from '../sketchObjects/Player'; import { Player } from '../sketchObjects/Player';
import store from '../store'; import store from '../store';
import { Scenes } from './scenes'; import { Scenes } from './scenes';
export class DetailScene { export class DetailScene {
player: Player; player: Player;
contributors: any;
legacy: any;
packages: any;
constructor() { constructor() {
this.player = new Player(); this.player = new Player();
store.subscribe((state) => {
this.contributors = state.currContributors;
this.legacy = state.currLegacy;
this.packages = state.currPackages;
});
} }
draw() { draw() {
mp5.background(100); mp5.background(mp5.color(colors.greyLighter));
this.player.follow(); this.player.follow();
this.player.move(); this.player.move();
// TODO: Draw what can be found
} }
onSceneClick() { onSceneClick() {

View file

@ -36,6 +36,7 @@ export class OverviewScene {
this.edges.forEach((edge, i) => { this.edges.forEach((edge, i) => {
const dist = mp5.dist(mp5.mouseX, mp5.mouseY, edge.x, edge.y); const dist = mp5.dist(mp5.mouseX, mp5.mouseY, edge.x, edge.y);
if (dist < edge.r) { if (dist < edge.r) {
store.getState().setDetailScene(edge.name);
store.setState({ currentScene: Scenes.DETAIL }); store.setState({ currentScene: Scenes.DETAIL });
} }
}); });

View file

@ -0,0 +1,24 @@
import { mp5 } from '../../main';
import { colors } from '../constants/colors';
export class Contributor {
x: number;
y: number;
size: number;
name: string;
profileURL: string;
revealed: boolean;
constructor(x: number, y: number, size: number, name?: string, profileURL?: string) {
this.x = x;
this.y = y;
this.size = size;
}
public place() {}
private draw() {
mp5.fill(mp5.color(colors.blueGrey));
mp5.ellipse(this.x, this.y, this.size);
}
}

View file

@ -2,12 +2,19 @@ import create from 'zustand/vanilla';
import { devtools } from 'zustand/middleware'; import { devtools } from 'zustand/middleware';
import { Scenes } from './scenes/scenes'; import { Scenes } from './scenes/scenes';
import { CompanionMessage, CompanionState } from './ui/companion'; import { CompanionMessage, CompanionState } from './ui/companion';
import project from '../metadata/project.json';
import { getSubproject } from './helpers';
import { SubProject } from './types';
export interface State { export interface State {
currentScene: Scenes; currentScene: Scenes;
companionState: CompanionState; companionState: CompanionState;
userMessages: CompanionMessage[]; userMessages: CompanionMessage[];
addUserMessage: (newMessage: CompanionMessage) => void; addUserMessage: (newMessage: CompanionMessage) => void;
currContributors: any;
currLegacy: any;
currPackages: any;
setDetailScene: (packageName: string) => void;
} }
const store = create<State>( const store = create<State>(
@ -17,6 +24,17 @@ const store = create<State>(
userMessages: [], userMessages: [],
addUserMessage: (newMessage) => addUserMessage: (newMessage) =>
set((state) => ({ userMessages: [...state.userMessages, newMessage] })), set((state) => ({ userMessages: [...state.userMessages, newMessage] })),
currContributors: [],
currLegacy: [],
currPackages: [],
setDetailScene: (packageName) =>
set(() => ({
currContributors: getSubproject(packageName, project.subprojects as SubProject[]).contents
.contributors,
currLegacy: getSubproject(packageName, project.subprojects as SubProject[]).contents.legacy,
currPackages: getSubproject(packageName, project.subprojects as SubProject[]).contents
.packages,
})),
})) }))
); );

View file

@ -2,7 +2,11 @@ export interface SubProject {
name: string; name: string;
path: string; path: string;
size: number; size: number;
contents: any; contents: {
contributors: any[];
legacy: any[];
packages: any[];
};
} }
export interface Coordinates { export interface Coordinates {