Browse Source

DRAGGABLE WINDOWS! :D

pull/1/head
asiekierka 8 years ago
parent
commit
6e8cde57be
4 changed files with 36 additions and 5 deletions
  1. 25
    1
      client/CraftrGame.java
  2. 7
    2
      client/CraftrWindow.java
  3. 2
    2
      common/CraftrVersion.java
  4. 2
    0
      test.sh

+ 25
- 1
client/CraftrGame.java View File

@@ -448,6 +448,11 @@ implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, F
public void mouseEntered(MouseEvent ev) {}
public void mouseExited(MouseEvent ev) {}
public void mouseClicked(MouseEvent ev) {}
public boolean isDragging = false;
public int dragX = 0;
public int dragY = 0;
public int dragID = 0;
public void mousePressed(MouseEvent ev)
{
mb = ev.getButton();
@@ -580,6 +585,12 @@ implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, F
default:
break;
}
} else if(insideRect(mx,my,cw.x<<3,cw.y<<3,cw.w<<3,cw.h<<3))
{ // DRAGGING WINDOWS! :D
dragX = (mx-(cw.x<<3))>>3;
dragY = (my-(cw.y<<3))>>3;
dragID = gs.windows.indexOf(cw);
isDragging = true;
}
}
}
@@ -604,10 +615,23 @@ implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, F
int ty = (players[255].py+(my>>4))-12;
gs.hov_type=map.getBlock(tx,ty).getTypeWithVirtual();
}
if(isDragging)
{
synchronized(gs.windows)
{
CraftrWindow dcw = gs.windows.get(dragID);
int dragRX = (mx-((dcw.x+dragX)<<3))>>3;
int dragRY = (my-((dcw.y+dragY)<<3))>>3;
dcw.x+=dragRX;
dcw.y+=dragRY;
gs.windows.set(dragID,dcw);
}
if(mb != ev_1) isDragging = false;
}
}
public void processMouse()
{
if(mb != ev_no && canMousePress)
if(mb != ev_no && canMousePress && !isDragging)
{
if(insideRect(mx,my,0,0,canvas.WIDTH,(canvas.GRID_H<<4)) && !gs.inWindow(mx,my))
{

+ 7
- 2
client/CraftrWindow.java View File

@@ -21,6 +21,7 @@ public class CraftrWindow
public static final String[] note_names={"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
public static final String[] drum_names={"Kick","Snare","(C) HiHat","(O) HiHat","HiTom","MidTom","LoTom","Crash"};
public int uid;
private int oldtype;
public CraftrWindow(int _type, int _uid)
{
@@ -67,8 +68,12 @@ public class CraftrWindow
title = "ERROR!";
break;
}
x = 32-(w>>1);
y = 25-(h>>1);
if(oldtype!=type)
{
oldtype=type;
x = 32-(w>>1);
y = 25-(h>>1);
}
}
static

+ 2
- 2
common/CraftrVersion.java View File

@@ -5,8 +5,8 @@ public class CraftrVersion
private static final int protocolVer = 258;
private static final int releaseVer = 0;
private static final int majorVer = 1;
private static final int minorVer = 3;
private static final int patchVer = 1;
private static final int minorVer = 4;
private static final int patchVer = 0;
public CraftrVersion()
{
}

+ 2
- 0
test.sh View File

@@ -0,0 +1,2 @@
#!/bin/sh
java -jar 64pixels.jar

Loading…
Cancel
Save