245 lines
5.0 KiB
Plaintext
245 lines
5.0 KiB
Plaintext
int imgW;
|
|
int imgH;
|
|
|
|
int centerX;
|
|
int centerY;
|
|
|
|
int scale = 1;
|
|
int maxScale = 5;
|
|
float zoomFactor = 0.4;
|
|
|
|
int panFromX;
|
|
int panFromY;
|
|
|
|
int panToX;
|
|
int panToY;
|
|
|
|
int xShift = 0;
|
|
int yShift = 0;
|
|
|
|
boolean map_click, click_init, drag;
|
|
boolean globalplay = true;
|
|
float avgClick;
|
|
boolean waitClick;
|
|
|
|
void mousePressed(){
|
|
if(mouseButton == LEFT){
|
|
if(!click_init){
|
|
if (!(mouseX > timeline.xpos && mouseY > timeline.ypos &&
|
|
mouseX < timeline.xpos + timeline.swidth && mouseY < timeline.ypos + timeline.sheight)){
|
|
map_click = true;
|
|
} else {
|
|
map_click = false;
|
|
}
|
|
|
|
// if(timeline.over){
|
|
// avgClick = 0;
|
|
// timeline.play = false;
|
|
// }
|
|
if (timeline.over_play){
|
|
if (!timeline.play) {
|
|
timeline.play = true;
|
|
globalplay = true;
|
|
} else {
|
|
timeline.play = false;
|
|
globalplay = false;
|
|
}
|
|
}
|
|
|
|
|
|
if(topBar.hoverInfo){
|
|
topBar.infoActive = true;
|
|
topBar.bilderActive = false;
|
|
topBar.videosActive = false;
|
|
topBar.panelActive = true;
|
|
}
|
|
if(topBar.hoverBilder){
|
|
topBar.bilderActive = true;
|
|
topBar.infoActive = false;
|
|
topBar.videosActive = false;
|
|
topBar.panelActive = true;
|
|
}
|
|
if(topBar.hoverVideos){
|
|
topBar.videosActive = true;
|
|
topBar.infoActive = false;
|
|
topBar.bilderActive = false;
|
|
topBar.panelActive = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < infopoints.length; i++){
|
|
|
|
if((infopoints[i].hover || infopoints[i].hover2) && !infopoints[i].clicked && !infopoints[i].endicon && !infopoints[i].initicon && !topBar.hover){
|
|
|
|
infopoints[i].clicked = true;
|
|
topBar.info(i);
|
|
// if(avgClick == 0){
|
|
topBar.init();
|
|
// }
|
|
avgClick++;
|
|
if(globalplay && timeline.play == true){
|
|
timeline.play = false;
|
|
}
|
|
|
|
if(infopoints[i].hover2){
|
|
waitClick = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < rbuttons.length; i++){
|
|
if(rbuttons[i].hover){
|
|
if(!rbuttons[i].clicked){
|
|
rbuttons[i].clicked = true;
|
|
} else {
|
|
rbuttons[i].clicked = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
click_init = true;
|
|
|
|
|
|
}
|
|
}
|
|
if(map_click){
|
|
panFromX = mouseX;
|
|
panFromY = mouseY;
|
|
}
|
|
// } else {
|
|
//
|
|
// topBar.finish();
|
|
// }
|
|
}
|
|
|
|
|
|
|
|
void mouseReleased(){
|
|
if(mouseButton == LEFT){
|
|
click_init = false;
|
|
|
|
for(int i = 0; i < infopoints.length; i++){
|
|
if (infopoints[i].clicked && !drag && !infopoints[i].hover && !infopoints[i].hover2 && !topBar.hover && !topBar.panelHover && !timeline.over_play && !waitClick) {
|
|
infopoints[i].clicked = false;
|
|
|
|
avgClick--;
|
|
}
|
|
if(avgClick == 0){
|
|
topBar.finish();
|
|
if(globalplay){
|
|
timeline.play = true;
|
|
}
|
|
|
|
}
|
|
}
|
|
waitClick = false;
|
|
if(drag){
|
|
drag = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
void mouseDragged(){
|
|
|
|
if(mouseButton == LEFT){
|
|
if(map_click){
|
|
drag = true;
|
|
panToX = mouseX;
|
|
panToY = mouseY;
|
|
|
|
xShift = panToX - panFromX;
|
|
yShift = panToY - panFromY;
|
|
|
|
if(centerX - imgW / 2 <= 0
|
|
&& centerX + imgW / 2 >= width
|
|
&& centerY - imgH / 2 <= 0
|
|
&& centerY + imgH / 2 >= height){
|
|
centerX = centerX + xShift;
|
|
centerY = centerY + yShift;
|
|
}
|
|
|
|
if(centerX - imgW / 2 > 0){
|
|
centerX = imgW / 2;
|
|
}
|
|
|
|
if(centerX + imgW / 2 < width){
|
|
centerX = width - imgW / 2;
|
|
}
|
|
|
|
if(centerY - imgH / 2 > 0){
|
|
centerY = imgH / 2;
|
|
}
|
|
|
|
if(centerY + imgH / 2 < height){
|
|
centerY = height - imgH / 2;
|
|
}
|
|
|
|
panFromX = panToX;
|
|
panFromY = panToY;
|
|
}
|
|
}
|
|
}
|
|
|
|
//Zoom
|
|
void mouseWheel(MouseEvent event) {
|
|
float e = event.getAmount();
|
|
|
|
if(e == -1){
|
|
if(scale < maxScale){
|
|
scale++;
|
|
imgW = int(imgW * (1+zoomFactor));
|
|
imgH = int(imgH * (1+zoomFactor));
|
|
|
|
int oldCenterX = centerX;
|
|
int oldCenterY = centerY;
|
|
|
|
centerX = centerX - int(zoomFactor * (mouseX - centerX));
|
|
centerY = centerY - int(zoomFactor * (mouseY - centerY));
|
|
}
|
|
}
|
|
|
|
if(e == 1){
|
|
|
|
if(scale > 1){
|
|
scale--;
|
|
imgH = int(imgH/(1+zoomFactor));
|
|
imgW = int(imgW/(1+zoomFactor));
|
|
|
|
int oldCenterX = centerX;
|
|
int oldCenterY = centerY;
|
|
|
|
centerX = centerX + int((mouseX - centerX)
|
|
* (zoomFactor/(zoomFactor + 1)));
|
|
centerY = centerY + int((mouseY - centerY)
|
|
* (zoomFactor/(zoomFactor + 1)));
|
|
|
|
if(centerX - imgW / 2 > 0){
|
|
centerX = imgW / 2;
|
|
}
|
|
|
|
if(centerX + imgW / 2 < width){
|
|
centerX = width - imgW / 2;
|
|
}
|
|
|
|
if(centerY - imgH / 2 > 0){
|
|
centerY = imgH / 2;
|
|
}
|
|
|
|
if(centerY + imgH / 2 < height){
|
|
centerY = height - imgH / 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(scale == 1){
|
|
imgW = int(map.width/scaleAmount);
|
|
imgH = int(map.height/scaleAmount);
|
|
centerX = window_w/2;
|
|
centerY = window_h/2;
|
|
}
|
|
}
|
|
|