Sketcher2 source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

package com.jotuntech.sketcher.client.command;
import java.nio.ByteBuffer;
import com.jotuntech.sketcher.client.Client;
import com.jotuntech.sketcher.client.Command;
import com.jotuntech.sketcher.client.Connection;
import com.jotuntech.sketcher.client.Editor;
import com.jotuntech.sketcher.common.Brush;
import com.jotuntech.sketcher.common.User;
public class SetBrushCommand implements Command {
Brush brush;
public SetBrushCommand() {
}
public SetBrushCommand(Brush brush) {
this.brush = brush;
}
public int perform(Client client, User user) {
if(user == null) {
/** Signed in users only */
return Connection.SEND_NONE;
}
if(user.isViewer()) {
return Connection.SEND_NONE;
}
Brush oldBrush = user.getBrush();
user.setBrush(brush);
if(user == client.getConnection().getUser()) {
/** Update the GUI */
client.getUserInterface().updateBrushSliders();
if(oldBrush == null) {
/* Enable editor when first brush is selected */
client.getUserInterface().getEditor().setState(Editor.State.DRAW_HOVER);
}
}
return Connection.SEND_OTHERS;
}
public void decode(ByteBuffer in) {
brush = new Brush();
brush.decode(in);
}
public void encode(ByteBuffer out) {
brush.encode(out);
}
}