Added files
This commit is contained in:
parent
6aae6d281e
commit
f3dc04df21
38 changed files with 3103 additions and 0 deletions
10
VirtualComputer/.classpath
Normal file
10
VirtualComputer/.classpath
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server (build)/spigot-1.8.7.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Downloads/jni4net-0.8.8.0-bin/lib/jni4net.j-0.8.8.0.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server/plugins/VirtualComputer/VirtualComputerSender.j4n.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Z - Norbi cucca/0 Projektek/TheButtonMCAutoFlairProto/Spigot server/plugins/_/Movecraft.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
17
VirtualComputer/.project
Normal file
17
VirtualComputer/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>VirtualComputer</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
VirtualComputer/.settings/org.eclipse.jdt.core.prefs
Normal file
11
VirtualComputer/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
BIN
VirtualComputer/VirtualComputerSender.j4n.jar
Normal file
BIN
VirtualComputer/VirtualComputerSender.j4n.jar
Normal file
Binary file not shown.
BIN
VirtualComputer/jni4net.j-0.8.8.0.jar
Normal file
BIN
VirtualComputer/jni4net.j-0.8.8.0.jar
Normal file
Binary file not shown.
BIN
VirtualComputer/jni4net.n-0.8.8.0.dll
Normal file
BIN
VirtualComputer/jni4net.n-0.8.8.0.dll
Normal file
Binary file not shown.
BIN
VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll
Normal file
BIN
VirtualComputer/jni4net.n.w64.v40-0.8.8.0.dll
Normal file
Binary file not shown.
8
VirtualComputer/plugin.yml
Normal file
8
VirtualComputer/plugin.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
name: VirtualComputer
|
||||
main: sznp.virtualcomputer.PluginMain
|
||||
version: 1.0
|
||||
commands:
|
||||
computer:
|
||||
usage: Use /computer start|stop
|
||||
alias: c
|
||||
depend: [Movecraft]
|
|
@ -0,0 +1,217 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap;
|
||||
|
||||
/*
|
||||
* This file was originally taken from https://github.com/slipswhitley/SketchMap
|
||||
*/
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.mcplugindev.slipswhitley.sketchmap.file.SketchMapFileException;
|
||||
import com.mcplugindev.slipswhitley.sketchmap.map.RelativeLocation;
|
||||
import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap;
|
||||
|
||||
//import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap.BaseFormat;
|
||||
|
||||
public class SketchMapAPI
|
||||
{
|
||||
|
||||
public static SketchMap getMapByID(String id)
|
||||
{
|
||||
for (SketchMap map : SketchMap.getLoadedMaps())
|
||||
{
|
||||
if (map.getID().equalsIgnoreCase(id))
|
||||
{
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOrderedItemSet(SketchMap map)
|
||||
{
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
|
||||
for (int y = 0; y < map.getLengthY(); y++)
|
||||
{
|
||||
for (int x = 0; x < map.getLengthX(); x++)
|
||||
{
|
||||
for (RelativeLocation loc : map.getMapCollection().keySet())
|
||||
{
|
||||
if (loc.getX() != x || loc.getY() != y)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack iStack = new ItemStack(Material.MAP, 1);
|
||||
iStack.setDurability(SketchMapUtils.getMapID(map
|
||||
.getMapCollection().get(loc)));
|
||||
|
||||
ItemMeta iMeta = iStack.getItemMeta();
|
||||
iMeta.setDisplayName(ChatColor.GREEN + "SketchMap ID: "
|
||||
+ ChatColor.GOLD + map.getID() + ChatColor.GREEN
|
||||
+ " Pos-X: " + ChatColor.GOLD + (x + 1)
|
||||
+ ChatColor.GREEN + " Pos-Y: " + ChatColor.GOLD
|
||||
+ (y + 1));
|
||||
|
||||
iMeta.setLore(Arrays.asList(new String[] { ChatColor.GRAY
|
||||
+ "SketchMap ID: " + map.getID()
|
||||
|
||||
}));
|
||||
|
||||
iStack.setItemMeta(iMeta);
|
||||
items.add(iStack);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public static SketchMap loadSketchMapFromFile(File file)
|
||||
throws SketchMapFileException
|
||||
{
|
||||
|
||||
YamlConfiguration config = null;
|
||||
try
|
||||
{
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
throw new SketchMapFileException("Invalid SketchMap File \""
|
||||
+ file.getName() + "\"");
|
||||
}
|
||||
|
||||
String[] fieldSet = { "x-panes", "y-panes", "public-protected",
|
||||
"map-collection", "base-format", "map-image", };
|
||||
|
||||
for (String field : fieldSet)
|
||||
{
|
||||
if (!config.isSet(field))
|
||||
{
|
||||
throw new SketchMapFileException(
|
||||
"Unable to load SketchMap file \"" + file.getName()
|
||||
+ "\" missing field \"" + field + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
Integer xPanes = config.getInt("x-panes");
|
||||
if (xPanes == null || xPanes < 1)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName() + "\" invalid field \"x-panes\"");
|
||||
}
|
||||
|
||||
Integer yPanes = config.getInt("y-panes");
|
||||
if (yPanes == null || yPanes < 1)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName() + "\" invalid field \"y-panes\"");
|
||||
}
|
||||
|
||||
Boolean publicProtected = config.getBoolean("public-protected");
|
||||
if (publicProtected == null)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName() + "\" invalid field \"public-protected\"");
|
||||
}
|
||||
|
||||
List<String> mapList = config.getStringList("map-collection");
|
||||
if (mapList == null)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName() + "\" invalid field \"map-collection\"");
|
||||
}
|
||||
|
||||
Map<Short, RelativeLocation> mapCollection = new HashMap<Short, RelativeLocation>();
|
||||
|
||||
for (String map : mapList)
|
||||
{
|
||||
String[] split = map.split(" ");
|
||||
if (split.length != 2)
|
||||
{
|
||||
throw new SketchMapFileException(
|
||||
"Unable to load SketchMap file \"" + file.getName()
|
||||
+ "\" cannot parse field in \"map-colection\"");
|
||||
}
|
||||
|
||||
RelativeLocation loc = RelativeLocation.fromString(split[0]);
|
||||
|
||||
if (loc == null)
|
||||
{
|
||||
throw new SketchMapFileException(
|
||||
"Unable to load SketchMap file \"" + file.getName()
|
||||
+ "\" cannot parse field in \"map-colection\"");
|
||||
}
|
||||
|
||||
Short id = null;
|
||||
try
|
||||
{
|
||||
id = Short.parseShort(split[1]);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
throw new SketchMapFileException(
|
||||
"Unable to load SketchMap file \"" + file.getName()
|
||||
+ "\" cannot parse field in \"map-colection\"");
|
||||
}
|
||||
|
||||
mapCollection.put(id, loc);
|
||||
}
|
||||
|
||||
//BaseFormat format = null;
|
||||
/*
|
||||
* try {
|
||||
* format = BaseFormat.valueOf(config.getString("base-format"));
|
||||
* }
|
||||
* catch (Exception ex) {
|
||||
* throw new SketchMapFileException("Unable to load SketchMap file \"" +
|
||||
* file.getName()
|
||||
* + "\" cannot parse BaseFormat from field \"base-format\"");
|
||||
* }
|
||||
*/
|
||||
|
||||
String b64Img = config.getString("map-image");
|
||||
if (b64Img == null)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName() + "\" invalid field \"map-image\"");
|
||||
}
|
||||
|
||||
BufferedImage image = null;
|
||||
|
||||
try
|
||||
{
|
||||
image = SketchMapUtils.base64StringToImg(b64Img);
|
||||
} catch (Exception ex)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName()
|
||||
+ "\" parse image from field \"map-image\"");
|
||||
}
|
||||
|
||||
String imageID = file.getName().substring(0,
|
||||
file.getName().lastIndexOf("."));
|
||||
if (getMapByID(imageID) != null)
|
||||
{
|
||||
throw new SketchMapFileException("Unable to load SketchMap file \""
|
||||
+ file.getName()
|
||||
+ "\" A SketchMap by that ID already exists.");
|
||||
}
|
||||
|
||||
return new SketchMap(image, imageID, yPanes, yPanes, publicProtected);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap;
|
||||
|
||||
/*
|
||||
* This file was originally taken from https://github.com/slipswhitley/SketchMap
|
||||
*/
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.mcplugindev.slipswhitley.sketchmap.listener.PlayerListener;
|
||||
|
||||
public class SketchMapPlugin extends JavaPlugin
|
||||
{
|
||||
private static SketchMapPlugin plugin;
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
plugin = this;
|
||||
|
||||
setupListeners();
|
||||
|
||||
sendEnabledMessage();
|
||||
}
|
||||
|
||||
private void sendEnabledMessage()
|
||||
{
|
||||
SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN
|
||||
+ "| |");
|
||||
|
||||
SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| "
|
||||
+ ChatColor.AQUA + "SketchMap "
|
||||
+ this.getDescription().getVersion() + " has been Enabled!"
|
||||
+ ChatColor.GREEN + " |");
|
||||
|
||||
SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN + "| "
|
||||
+ ChatColor.AQUA + " Authors: SlipsWhitley & Fyrinlight"
|
||||
+ ChatColor.GREEN + " |");
|
||||
|
||||
SketchMapUtils.sendColoredConsoleMessage(ChatColor.GREEN
|
||||
+ "| |");
|
||||
}
|
||||
|
||||
private void setupListeners()
|
||||
{
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
}
|
||||
|
||||
public static SketchMapPlugin getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap;
|
||||
|
||||
/*
|
||||
* This file was originally taken from https://github.com/slipswhitley/SketchMap
|
||||
*/
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.Base64;
|
||||
import java.util.HashSet;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
public class SketchMapUtils
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* Image Utils
|
||||
*
|
||||
*/
|
||||
|
||||
public static BufferedImage resize(Image img, Integer width, Integer height)
|
||||
{
|
||||
|
||||
img = img.getScaledInstance(width, height, Image.SCALE_SMOOTH);
|
||||
|
||||
if (img instanceof BufferedImage)
|
||||
{
|
||||
return (BufferedImage) img;
|
||||
}
|
||||
|
||||
BufferedImage bimage = new BufferedImage(img.getWidth(null),
|
||||
img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
|
||||
Graphics2D bGr = bimage.createGraphics();
|
||||
bGr.drawImage(img, 0, 0, null);
|
||||
bGr.dispose();
|
||||
|
||||
return bimage;
|
||||
}
|
||||
|
||||
public static BufferedImage base64StringToImg(final String base64String)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ImageIO.read(new ByteArrayInputStream(Base64.getDecoder()
|
||||
.decode(base64String)));
|
||||
} catch (final IOException ioe)
|
||||
{
|
||||
throw new UncheckedIOException(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendColoredConsoleMessage(String msg)
|
||||
{
|
||||
ConsoleCommandSender sender = Bukkit.getConsoleSender();
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated Methods Here :'c
|
||||
*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static short getMapID(MapView map)
|
||||
{
|
||||
return map.getId();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static MapView getMapView(short id)
|
||||
{
|
||||
MapView map = Bukkit.getMap(id);
|
||||
if (map != null)
|
||||
{
|
||||
return map;
|
||||
}
|
||||
|
||||
return Bukkit.createMap(getDefaultWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
public static Block getTargetBlock(Player player, int i)
|
||||
{
|
||||
return player.getTargetBlock((HashSet<Material>) null, i);
|
||||
}
|
||||
|
||||
public static World getDefaultWorld()
|
||||
{
|
||||
return Bukkit.getWorlds().get(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap.file;
|
||||
|
||||
public class SketchMapFileException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SketchMapFileException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap.listener;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||
if(!(event.getRightClicked() instanceof ItemFrame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemFrame iFrame = (ItemFrame) event.getRightClicked();
|
||||
ItemStack iHand = event.getPlayer().getItemInHand();
|
||||
|
||||
if(iHand.getType() != Material.MAP) {
|
||||
return;
|
||||
}
|
||||
|
||||
String lore = iHand.getItemMeta().getLore().get(0);
|
||||
|
||||
if(!ChatColor.stripColor(lore).startsWith("SketchMap ID:")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(iFrame.getItem().getType() != Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
|
||||
ItemStack frameItem = iHand.clone();
|
||||
frameItem.setAmount(1);
|
||||
ItemMeta frameIMeta = frameItem.getItemMeta();
|
||||
|
||||
frameIMeta.setDisplayName("");
|
||||
frameItem.setItemMeta(frameIMeta);
|
||||
|
||||
iFrame.setItem(frameItem);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if(player.getGameMode() == GameMode.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(iHand.getAmount() == 1) {
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
return;
|
||||
}
|
||||
|
||||
iHand.setAmount(iHand.getAmount() - 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap.map;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapRenderer;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
public class ImageRenderer extends MapRenderer
|
||||
{
|
||||
|
||||
private BufferedImage image;
|
||||
|
||||
//private Boolean imageRendered;
|
||||
|
||||
public ImageRenderer(BufferedImage image)
|
||||
{
|
||||
this.image = image;
|
||||
//this.imageRendered = false;
|
||||
}
|
||||
|
||||
private int progress = 0;
|
||||
//private final int updatepixels = 20;
|
||||
public static int updatepixels = 15;
|
||||
|
||||
@Override
|
||||
public void render(MapView view, MapCanvas canvas, Player player)
|
||||
{
|
||||
/*
|
||||
* if(imageRendered) {
|
||||
* return;
|
||||
* }
|
||||
*/
|
||||
|
||||
long time = System.nanoTime();
|
||||
|
||||
try
|
||||
{
|
||||
//if (progress != 128 / updatepixels) //<-- Never had an issue with this before 2016.02.20. because I wasn't using 16 as updatepixels
|
||||
canvas.drawImage(0, progress * updatepixels, image.getSubimage(0,
|
||||
progress * updatepixels, 128, (progress * updatepixels
|
||||
+ updatepixels >= 128 ? 128 - progress
|
||||
* updatepixels : updatepixels)));
|
||||
if (progress < 128 / updatepixels)
|
||||
progress++;
|
||||
else
|
||||
progress = 0;
|
||||
//this.imageRendered = true;
|
||||
|
||||
long diff = System.nanoTime() - time;
|
||||
if (TimeUnit.NANOSECONDS.toMillis(diff) > 40)
|
||||
{
|
||||
System.out.println("Map rendering took "
|
||||
+ TimeUnit.NANOSECONDS.toMillis(diff) + " ms");
|
||||
/*
|
||||
* if (progress == 0 && updatepixels > 5)
|
||||
* updatepixels--;
|
||||
*/
|
||||
} /*
|
||||
* else if (TimeUnit.NANOSECONDS.toMillis(diff) < 25)
|
||||
* if (progress == 0 && updatepixels < 50)
|
||||
* updatepixels++;
|
||||
*/
|
||||
/*
|
||||
* if (progress >= 128 / updatepixels)
|
||||
* progress = 0;
|
||||
*/
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.out.println("Progess: " + progress);
|
||||
System.out.println("UpdatePixels: " + updatepixels);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap.map;
|
||||
|
||||
public class RelativeLocation {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
public RelativeLocation (int x, int y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return x + ":" + y;
|
||||
}
|
||||
|
||||
public static RelativeLocation fromString(String str) {
|
||||
String[] args = str.split(":");
|
||||
if(args.length != 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
try {
|
||||
x = Integer.parseInt(args[0]);
|
||||
y = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new RelativeLocation (x, y);
|
||||
}
|
||||
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package com.mcplugindev.slipswhitley.sketchmap.map;
|
||||
|
||||
/*
|
||||
* This file was originally taken from https://github.com/slipswhitley/SketchMap
|
||||
*/
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import com.mcplugindev.slipswhitley.sketchmap.SketchMapUtils;
|
||||
|
||||
public class SketchMap
|
||||
{
|
||||
|
||||
public BufferedImage image;
|
||||
private String mapID;
|
||||
private Integer xPanes;
|
||||
private Integer yPanes;
|
||||
private Boolean publicProtected;
|
||||
//private BaseFormat format;
|
||||
|
||||
private Map<RelativeLocation, MapView> mapCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* Create SketchMap using New Maps
|
||||
*
|
||||
*/
|
||||
|
||||
public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes,
|
||||
boolean publicProtected)
|
||||
{
|
||||
|
||||
this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128);
|
||||
this.mapID = mapID;
|
||||
this.xPanes = xPanes;
|
||||
this.yPanes = yPanes;
|
||||
this.publicProtected = publicProtected;
|
||||
//this.format = format;
|
||||
|
||||
this.mapCollection = new HashMap<RelativeLocation, MapView>();
|
||||
|
||||
getLoadedMaps().add(this);
|
||||
loadSketchMap();
|
||||
}
|
||||
|
||||
private void loadSketchMap()
|
||||
{
|
||||
for (int x = 0; x < xPanes; x++)
|
||||
{
|
||||
for (int y = 0; y < yPanes; y++)
|
||||
{
|
||||
initMap(x, y,
|
||||
Bukkit.createMap(SketchMapUtils.getDefaultWorld()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create SketchMap using Specified Maps
|
||||
*
|
||||
*/
|
||||
|
||||
public SketchMap(BufferedImage image, String mapID, int xPanes, int yPanes,
|
||||
boolean publicProtected, Map<Short, RelativeLocation> mapCollection)
|
||||
{
|
||||
|
||||
this.image = SketchMapUtils.resize(image, xPanes * 128, yPanes * 128);
|
||||
this.mapID = mapID;
|
||||
this.xPanes = xPanes;
|
||||
this.yPanes = yPanes;
|
||||
this.publicProtected = publicProtected;
|
||||
//this.format = format;
|
||||
|
||||
this.mapCollection = new HashMap<RelativeLocation, MapView>();
|
||||
|
||||
getLoadedMaps().add(this);
|
||||
loadSketchMap(mapCollection);
|
||||
}
|
||||
|
||||
private void loadSketchMap(Map<Short, RelativeLocation> mapCollection)
|
||||
{
|
||||
for (Short mapID : mapCollection.keySet())
|
||||
{
|
||||
RelativeLocation loc = mapCollection.get(mapID);
|
||||
|
||||
initMap(loc.getX(), loc.getY(), SketchMapUtils.getMapView(mapID));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private void initMap(int x, int y, MapView mapView)
|
||||
{
|
||||
BufferedImage subImage = image.getSubimage(x * 128, y * 128, 128, 128);
|
||||
mapView.getRenderers().clear();
|
||||
mapView.addRenderer(new ImageRenderer(subImage));
|
||||
|
||||
mapCollection.put(new RelativeLocation(x, y), mapView);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Get Object information
|
||||
*
|
||||
*/
|
||||
|
||||
public String getID()
|
||||
{
|
||||
return mapID;
|
||||
}
|
||||
|
||||
public BufferedImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
public int getLengthX()
|
||||
{
|
||||
return xPanes;
|
||||
}
|
||||
|
||||
public int getLengthY()
|
||||
{
|
||||
return yPanes;
|
||||
}
|
||||
|
||||
public boolean isPublicProtected()
|
||||
{
|
||||
return publicProtected;
|
||||
}
|
||||
|
||||
public Map<RelativeLocation, MapView> getMapCollection()
|
||||
{
|
||||
return mapCollection;
|
||||
}
|
||||
|
||||
/*
|
||||
* public BaseFormat getBaseFormat() {
|
||||
* return format;
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* Map Functions
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public void delete()
|
||||
{
|
||||
getLoadedMaps().remove(this);
|
||||
|
||||
try
|
||||
{
|
||||
this.finalize();
|
||||
} catch (Throwable e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Static Methods
|
||||
*
|
||||
*/
|
||||
|
||||
private static Set<SketchMap> sketchMaps;
|
||||
|
||||
public static Set<SketchMap> getLoadedMaps()
|
||||
{
|
||||
if (sketchMaps == null)
|
||||
{
|
||||
sketchMaps = new HashSet<SketchMap>();
|
||||
}
|
||||
|
||||
return sketchMaps;
|
||||
}
|
||||
|
||||
/*
|
||||
* public enum BaseFormat {
|
||||
* PNG,
|
||||
* JPEG;
|
||||
*
|
||||
* public String getExtension() {
|
||||
* if(this == BaseFormat.PNG) {
|
||||
* return "png";
|
||||
* }
|
||||
* if(this == BaseFormat.JPEG) {
|
||||
* return "jpg";
|
||||
* }
|
||||
* return null;
|
||||
* }
|
||||
*
|
||||
* public static BaseFormat fromExtension(String ext) {
|
||||
* if(ext.equalsIgnoreCase("png")) {
|
||||
* return BaseFormat.PNG;
|
||||
*
|
||||
* }
|
||||
* if(ext.equalsIgnoreCase("jpg")) {
|
||||
* return BaseFormat.JPEG;
|
||||
* }
|
||||
* return null;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
}
|
193
VirtualComputer/src/sznp/virtualcomputer/Commands.java
Normal file
193
VirtualComputer/src/sznp/virtualcomputer/Commands.java
Normal file
|
@ -0,0 +1,193 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import net.countercraft.movecraft.craft.Craft;
|
||||
import net.countercraft.movecraft.craft.CraftManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commands implements CommandExecutor
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
switch (cmd.getName().toLowerCase())
|
||||
{
|
||||
case "computer":
|
||||
{
|
||||
if (args.length == 0)
|
||||
return false;
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "start":
|
||||
PluginMain.getPlugin(PluginMain.class).Start(sender);
|
||||
break;
|
||||
case "stop":
|
||||
PluginMain.getPlugin(PluginMain.class).Stop(sender);
|
||||
break;
|
||||
case "debug":
|
||||
/*
|
||||
* sender.sendMessage("Screen length1: "
|
||||
* + PluginMain.Instance.Screen.length);
|
||||
* sender.sendMessage("Screen length2: "
|
||||
* + PluginMain.Instance.Screen[0].length);
|
||||
* sender.sendMessage("Screen length3: "
|
||||
* + PluginMain.Instance.Screen[0][0].length);
|
||||
*/
|
||||
/*
|
||||
* sender.sendMessage("UpdatePixels: "
|
||||
* + ImageRenderer.updatepixels);
|
||||
*/
|
||||
World w = Bukkit.getWorlds().get(0);
|
||||
Craft[] crafts = CraftManager.getInstance().getCraftsInWorld(w);
|
||||
sender.sendMessage("World: " + w);
|
||||
sender.sendMessage("Crafts: " + crafts);
|
||||
sender.sendMessage("Craft type: "
|
||||
+ crafts[0].getType().getCraftName());
|
||||
sender.sendMessage("DX: " + crafts[0].getLastDX());
|
||||
sender.sendMessage("DY: " + crafts[0].getLastDY());
|
||||
sender.sendMessage("DZ: " + crafts[0].getLastDZ());
|
||||
sender.sendMessage("MouseSpeed: " + PluginMain.MouseSpeed);
|
||||
sender.sendMessage("Block: "
|
||||
+ Bukkit.getWorlds()
|
||||
.get(0)
|
||||
.getBlockAt(crafts[0].getMinX(),
|
||||
crafts[0].getMinY() - 1,
|
||||
crafts[0].getMinZ()).getType()); //Block: AIR
|
||||
break;
|
||||
case "powerbutton":
|
||||
PluginMain.getPlugin(PluginMain.class).PowerButton(sender);
|
||||
break;
|
||||
case "reset":
|
||||
PluginMain.getPlugin(PluginMain.class).Reset(sender);
|
||||
break;
|
||||
case "fix":
|
||||
PluginMain.getPlugin(PluginMain.class).FixScreen(sender);
|
||||
break;
|
||||
case "key":
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /computer key <key> [down/up|interval]");
|
||||
return true;
|
||||
}
|
||||
if (args.length < 3)
|
||||
PluginMain.getPlugin(PluginMain.class).PressKey(sender,
|
||||
args[1], "");
|
||||
else
|
||||
PluginMain.getPlugin(PluginMain.class).PressKey(sender,
|
||||
args[1], args[2]);
|
||||
break;
|
||||
case "mouse":
|
||||
boolean showusage = true;
|
||||
if (args.length < 6)
|
||||
{
|
||||
//Command overloading, because I can :P
|
||||
if (args.length > 4) // 4<x<6
|
||||
{
|
||||
PluginMain.getPlugin(PluginMain.class).UpdateMouse(
|
||||
sender, Integer.parseInt(args[1]),
|
||||
Integer.parseInt(args[2]),
|
||||
Integer.parseInt(args[3]),
|
||||
Integer.parseInt(args[4]), "", false);
|
||||
showusage = false;
|
||||
} else
|
||||
{
|
||||
if (args.length == 3)
|
||||
{
|
||||
PluginMain.getPlugin(PluginMain.class).UpdateMouse(
|
||||
sender, 0, 0, 0, 0,
|
||||
//MouseButtonState.valueOf(args[1]),
|
||||
args[1], (args[2].equals("down")));
|
||||
showusage = false;
|
||||
} else if (args.length == 2)
|
||||
{
|
||||
PluginMain.getPlugin(PluginMain.class).UpdateMouse(
|
||||
sender, 0, 0, 0, 0,
|
||||
//MouseButtonState.valueOf(args[1]));
|
||||
args[1]);
|
||||
showusage = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (showusage)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /computer mouse <relx> <rely> <relz> <relw>");
|
||||
sender.sendMessage("§cOr: /computer mouse <button> [up/down]");
|
||||
}
|
||||
break;
|
||||
case "mspeed":
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /computer mspeed <speed>");
|
||||
return true;
|
||||
}
|
||||
PluginMain.MouseSpeed = Integer.parseInt(args[1]);
|
||||
sender.sendMessage("Mouse speed set to " + args[1]);
|
||||
break;
|
||||
case "input":
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
sender.sendMessage("§cError: Only players can use this command.");
|
||||
return true;
|
||||
}
|
||||
if (args.length < 2)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /computer input <key|mouse>");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("key"))
|
||||
{
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw "
|
||||
+ sender.getName()
|
||||
+ " [\"\",{\"text\":\" [0]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D0\"}},{\"text\":\" [1]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D1\"}},{\"text\":\" [2]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D2\"}},{\"text\":\" [3]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D3\"}},{\"text\":\" [4]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D4\"}},{\"text\":\" [5]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D5\"}},{\"text\":\" [6]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D6\"}},{\"text\":\" [7]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D7\"}},{\"text\":\" [8]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D8\"}},{\"text\":\" [9]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D9\"}}]");
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw "
|
||||
+ sender.getName()
|
||||
+ " [\"\",{\"text\":\" [Tab]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Tab\"}},{\"text\":\" [Q]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Q\"}},{\"text\":\" [W]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key W\"}},{\"text\":\" [E]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key E\"}},{\"text\":\" [R]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key R\"}},{\"text\":\" [T]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key T\"}},{\"text\":\" [Y]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Y\"}},{\"text\":\" [U]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key U\"}},{\"text\":\" [I]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key I\"}},{\"text\":\" [O]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key O\"}},{\"text\":\" [P]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key P\"}}]");
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw "
|
||||
+ sender.getName()
|
||||
+ " [\"\",{\"text\":\" [CapsLock]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key CapsLock\"}},{\"text\":\" [A]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key A\"}},{\"text\":\" [S]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key S\"}},{\"text\":\" [D]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key D\"}},{\"text\":\" [F]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key F\"}},{\"text\":\" [G]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key G\"}},{\"text\":\" [H]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key H\"}},{\"text\":\" [J]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key J\"}},{\"text\":\" [K]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key K\"}},{\"text\":\" [L]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key L\"}},{\"text\":\" [Return]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Return\"}}]");
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw "
|
||||
+ sender.getName()
|
||||
+ " [\"\",{\"text\":\" [Z]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Z\"}},{\"text\":\" [X]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key X\"}},{\"text\":\" [C]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key C\"}},{\"text\":\" [V]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key V\"}},{\"text\":\" [B]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key B\"}},{\"text\":\" [N]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key N\"}},{\"text\":\" [M]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key M\"}}]");
|
||||
Bukkit.getServer()
|
||||
.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
"tellraw "
|
||||
+ sender.getName()
|
||||
+ " [\"\",{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlLeft\"}},{\"text\":\" [Alt]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltLeft\"}},{\"text\":\" [Space]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key Space\"}},{\"text\":\" [AltGr]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key AltRight\"}},{\"text\":\" [Ctrl]\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/computer key ControlRight\"}}]");
|
||||
} else if (args[1].equalsIgnoreCase("mouse"))
|
||||
{
|
||||
MouseLockerPlayerListener.MouseLocked = !MouseLockerPlayerListener.MouseLocked;
|
||||
if (MouseLockerPlayerListener.MouseLocked)
|
||||
sender.sendMessage("§aMouse locked.");
|
||||
else
|
||||
sender.sendMessage("§bMouse unlocked.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
90
VirtualComputer/src/sznp/virtualcomputer/JarUtils.java
Normal file
90
VirtualComputer/src/sznp/virtualcomputer/JarUtils.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
public class JarUtils {
|
||||
|
||||
public static boolean extractFromJar(final String fileName,
|
||||
final String dest) throws IOException {
|
||||
if (getRunningJar() == null) {
|
||||
return false;
|
||||
}
|
||||
final File file = new File(dest);
|
||||
if (file.isDirectory()) {
|
||||
file.mkdir();
|
||||
return false;
|
||||
}
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
final JarFile jar = getRunningJar();
|
||||
final Enumeration<JarEntry> e = jar.entries();
|
||||
while (e.hasMoreElements()) {
|
||||
final JarEntry je = e.nextElement();
|
||||
if (!je.getName().contains(fileName)) {
|
||||
continue;
|
||||
}
|
||||
final InputStream in = new BufferedInputStream(
|
||||
jar.getInputStream(je));
|
||||
final OutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(file));
|
||||
copyInputStream(in, out);
|
||||
jar.close();
|
||||
return true;
|
||||
}
|
||||
jar.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
private final static void copyInputStream(final InputStream in,
|
||||
final OutputStream out) throws IOException {
|
||||
try {
|
||||
final byte[] buff = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buff)) > 0) {
|
||||
out.write(buff, 0, n);
|
||||
}
|
||||
} finally {
|
||||
out.flush();
|
||||
out.close();
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static URL getJarUrl(final File file) throws IOException {
|
||||
return new URL("jar:" + file.toURI().toURL().toExternalForm() + "!/");
|
||||
}
|
||||
|
||||
public static JarFile getRunningJar() throws IOException {
|
||||
if (!RUNNING_FROM_JAR) {
|
||||
return null; // null if not running from jar
|
||||
}
|
||||
String path = new File(JarUtils.class.getProtectionDomain()
|
||||
.getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
path = URLDecoder.decode(path, "UTF-8");
|
||||
return new JarFile(path);
|
||||
}
|
||||
|
||||
private static boolean RUNNING_FROM_JAR = false;
|
||||
|
||||
static {
|
||||
final URL resource = JarUtils.class.getClassLoader().getResource(
|
||||
"plugin.yml");
|
||||
if (resource != null) {
|
||||
RUNNING_FROM_JAR = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
@Deprecated
|
||||
public enum MouseButtonState
|
||||
{
|
||||
LeftButton(1), MiddleButton(4), MouseStateMask(127), RightButton(2), WheelDown(
|
||||
16), WheelUp(8), XButton1(32), XButton2(64), Null(0);
|
||||
|
||||
private final int val;
|
||||
|
||||
MouseButtonState(int val)
|
||||
{
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return val;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class MouseLockerPlayerListener implements Listener
|
||||
{
|
||||
public static boolean MouseLocked = false;
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMoveMouse(PlayerMoveEvent e)
|
||||
{
|
||||
if (!MouseLocked)
|
||||
return;
|
||||
float yaw1 = e.getFrom().getYaw();
|
||||
float pitch1 = e.getFrom().getPitch();
|
||||
float yaw2 = e.getTo().getYaw();
|
||||
float pitch2 = e.getTo().getPitch();
|
||||
|
||||
/*
|
||||
* System.out.println("yaw: " + (yaw2 - yaw1) + " pitch: "
|
||||
* + (pitch2 - pitch1));
|
||||
*/
|
||||
|
||||
PluginMain.Instance.UpdateMouse(null, (int) (yaw2 - yaw1),
|
||||
(int) (pitch2 - pitch1), 0, 0, "");
|
||||
|
||||
e.setTo(e.getFrom());
|
||||
}
|
||||
}
|
462
VirtualComputer/src/sznp/virtualcomputer/PluginMain.java
Normal file
462
VirtualComputer/src/sznp/virtualcomputer/PluginMain.java
Normal file
|
@ -0,0 +1,462 @@
|
|||
package sznp.virtualcomputer;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.countercraft.movecraft.craft.Craft;
|
||||
import net.countercraft.movecraft.craft.CraftManager;
|
||||
import net.sf.jni4net.Bridge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import virtualcomputersender.Computer;
|
||||
|
||||
import com.mcplugindev.slipswhitley.sketchmap.map.RelativeLocation;
|
||||
import com.mcplugindev.slipswhitley.sketchmap.map.SketchMap;
|
||||
|
||||
public class PluginMain extends JavaPlugin
|
||||
{
|
||||
private Computer computer;
|
||||
private SketchMap smap;
|
||||
|
||||
public static PluginMain Instance;
|
||||
|
||||
// Fired when plugin is first enabled
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
Instance = this;
|
||||
try
|
||||
{
|
||||
ConsoleCommandSender ccs = getServer().getConsoleSender();
|
||||
this.getCommand("computer").setExecutor(new Commands());
|
||||
ccs.sendMessage("§bExtracting necessary libraries...");
|
||||
final File[] libs = new File[] { // added to class path
|
||||
new File(getDataFolder(), "jni4net.j-0.8.8.0.jar"),
|
||||
new File(getDataFolder(), "VirtualComputerSender.j4n.jar") };
|
||||
final File[] libs2 = new File[] {
|
||||
new File(getDataFolder(), "jni4net.n-0.8.8.0.dll"),
|
||||
new File(getDataFolder(), "jni4net.n.w64.v40-0.8.8.0.dll") };
|
||||
for (final File lib : libs)
|
||||
{
|
||||
if (!lib.exists())
|
||||
{
|
||||
JarUtils.extractFromJar(lib.getName(),
|
||||
lib.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
for (final File lib : libs2)
|
||||
{
|
||||
if (!lib.exists())
|
||||
{
|
||||
JarUtils.extractFromJar(lib.getName(),
|
||||
lib.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
for (final File lib : libs)
|
||||
{
|
||||
if (!lib.exists())
|
||||
{
|
||||
getLogger().warning(
|
||||
"Failed to load plugin! Could not find lib: "
|
||||
+ lib.getName());
|
||||
Bukkit.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
addClassPath(JarUtils.getJarUrl(lib));
|
||||
}
|
||||
ccs.sendMessage("§bInitializing bridge...");
|
||||
// Bridge.setVerbose(true);
|
||||
// Bridge.setDebug(true);
|
||||
Bridge.init(new File(getDataFolder(),
|
||||
"jni4net.n.w64.v40-0.8.8.0.dll").getAbsoluteFile());
|
||||
Bridge.LoadAndRegisterAssemblyFrom(new File(getDataFolder(),
|
||||
"VirtualComputerSender.j4n.dll"));
|
||||
ccs.sendMessage("§bInititalizing VirtualBox interface...");
|
||||
computer = new Computer();
|
||||
//ccs.sendMessage("§bLoading ArmorStands...");
|
||||
ccs.sendMessage("§bLoading SketchMap...");
|
||||
/*
|
||||
* for (ArmorStand as : Bukkit.getWorlds().get(0)
|
||||
* .getEntitiesByClass(ArmorStand.class))
|
||||
* as.remove();
|
||||
*/
|
||||
/*
|
||||
* World world = Bukkit.getWorlds().get(0);
|
||||
* //armorstands = new ArmorStand[640][];
|
||||
* iframes = new ItemFrame[640][];
|
||||
* for (int i = 0; i < 640; i++)
|
||||
* {
|
||||
* //armorstands[i] = new ArmorStand[480];
|
||||
* iframes[i] = new ItemFrame[480];
|
||||
* for (int j = 0; j < 480; j++)
|
||||
* {
|
||||
* String id = getConfig().getString(i + "." + j);
|
||||
* if (id == null)
|
||||
* {
|
||||
* //armorstands[i][j] = null;
|
||||
* iframes[i][j] = null;
|
||||
* break;
|
||||
* }
|
||||
* UUID uuid = UUID.fromString(id);
|
||||
* for (Entity entity : world.getEntities())
|
||||
* {
|
||||
* if (entity.getUniqueId().equals(uuid))
|
||||
* {
|
||||
* //armorstands[i][j] = (ArmorStand) entity;
|
||||
* iframes[i][j] = (ItemFrame) entity;
|
||||
* break;
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
img = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB);
|
||||
HashMap<Short, RelativeLocation> map = new HashMap<>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
map.put((short) (i * 4 + j), new RelativeLocation(i, j));
|
||||
smap = new SketchMap(img, "Screen", 5, 4, false, map);
|
||||
ccs.sendMessage("§bLoaded!");
|
||||
DoStart();
|
||||
} catch (final Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Fired when plugin is disabled
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
ConsoleCommandSender ccs = getServer().getConsoleSender();
|
||||
//ccs.sendMessage("§aSaving ArmorStands...");
|
||||
//ccs.sendMessage("§aSaving Maps...");
|
||||
/*
|
||||
* for (int i = 0; i < iframes.length; i++)
|
||||
* {
|
||||
* for (int j = 0; j < iframes[i].length; j++)
|
||||
* {
|
||||
* if (iframes[i][j] == null)
|
||||
* break;
|
||||
* //getConfig().set(i + "." + j, armorstands[i][j].getUniqueId());
|
||||
* getConfig().set(i + "." + j, iframes[i][j].getUniqueId());
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
ccs.sendMessage("§aHuh.");
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
//private volatile ArmorStand[][] armorstands;
|
||||
//private volatile int ProgressX = 0;
|
||||
//private volatile int ProgressY = 0;
|
||||
//private volatile ItemFrame[][] iframes;
|
||||
private volatile BufferedImage img;
|
||||
private volatile int taskid = -1;
|
||||
|
||||
//public volatile byte[][][] Screen;
|
||||
|
||||
public void Start(CommandSender sender)
|
||||
{
|
||||
sender.sendMessage("§eStarting computer...");
|
||||
computer.Start();
|
||||
sender.sendMessage("§eComputer started.");
|
||||
DoStart();
|
||||
/*
|
||||
* this.getServer().getScheduler()
|
||||
* .scheduleSyncRepeatingTask(this, new Runnable()
|
||||
* {
|
||||
* public void run()
|
||||
* {
|
||||
* long worktime = TimeUnit.NANOSECONDS.toMillis(System
|
||||
* .nanoTime());
|
||||
*
|
||||
* if (ProgressX == 0 && ProgressY == 0)
|
||||
* Screen = computer.GetScreen();
|
||||
* if (Screen == null)
|
||||
* return;
|
||||
*
|
||||
* for (int i = ProgressX; i < 640; i++)
|
||||
* {
|
||||
* for (int j = ProgressY; j < 480; j++)
|
||||
* {
|
||||
* if (TimeUnit.NANOSECONDS.toMillis(System
|
||||
* .nanoTime()) - worktime > 40)
|
||||
* {
|
||||
* ProgressX = i;
|
||||
* ProgressY = j;
|
||||
* return;
|
||||
* }
|
||||
*
|
||||
* if (armorstands[i][j] == null)
|
||||
* armorstands[i][j] = (ArmorStand) Bukkit
|
||||
* .getWorlds()
|
||||
* .get(0)
|
||||
* .spawnEntity(
|
||||
* new Location(
|
||||
* Bukkit.getWorlds()
|
||||
* .get(0),
|
||||
* i * 0.1,
|
||||
* 80f - j * 0.1, 0f),
|
||||
* EntityType.ARMOR_STAND);
|
||||
*
|
||||
*
|
||||
* World world = Bukkit.getWorlds().get(0);
|
||||
* Location loc = new
|
||||
* Location(Bukkit.getWorlds()
|
||||
* .get(0), i * 0.1, 80f - j * 0.1, 0f);
|
||||
* if (iframes[i][j] == null)
|
||||
* iframes[i][j] = (ItemFrame) world
|
||||
* .spawnEntity(loc,
|
||||
* EntityType.ITEM_FRAME);
|
||||
*
|
||||
*
|
||||
* ItemStack stack = new ItemStack(
|
||||
* Material.LEATHER_CHESTPLATE, 1);
|
||||
* ((LeatherArmorMeta) stack.getItemMeta())
|
||||
* .setColor(Color.fromRGB(Byte
|
||||
* .toUnsignedInt(computer
|
||||
* .GetScreenPixelColor(i,
|
||||
* j, 0)), Byte
|
||||
* .toUnsignedInt(computer
|
||||
* .GetScreenPixelColor(i,
|
||||
* j, 1)), Byte
|
||||
* .toUnsignedInt(computer
|
||||
* .GetScreenPixelColor(i,
|
||||
* j, 2))));
|
||||
* armorstands[i][j].setChestplate(stack);
|
||||
* armorstands[i][j].setVisible(false);
|
||||
*
|
||||
* //iframes[i][j].setItem(); //TO!DO: Copy int array to BufferedImage
|
||||
* in
|
||||
* background thread while rendering
|
||||
* }
|
||||
* }
|
||||
* ProgressX = 0;
|
||||
* ProgressY = 0;
|
||||
* }
|
||||
* }, 1, 1);
|
||||
*/
|
||||
}
|
||||
|
||||
public static int MouseSpeed = 1;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void DoStart()
|
||||
{
|
||||
if (taskid == -1)
|
||||
taskid = this.getServer().getScheduler()
|
||||
.scheduleAsyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
//long time = System.nanoTime();
|
||||
|
||||
final int[] a = ((DataBufferInt) smap.image
|
||||
.getRaster().getDataBuffer()).getData();
|
||||
final int[] data = computer.GetScreenPixelColors();
|
||||
/*
|
||||
* if (data.length > 600)
|
||||
* System.out.println("Updating screen...");
|
||||
*/
|
||||
System.arraycopy(data, 0, a, 0, data.length);
|
||||
/*
|
||||
* if (data.length > 600)
|
||||
* System.out.println("Updated screen.");
|
||||
*/
|
||||
|
||||
/*
|
||||
* long diff = System.nanoTime() - time;
|
||||
* if (TimeUnit.NANOSECONDS.toMillis(diff) > 50)
|
||||
* System.out.println("Data copy took "
|
||||
* + TimeUnit.NANOSECONDS.toMillis(diff) + " ms");
|
||||
*/
|
||||
}
|
||||
}, 1, 10);
|
||||
this.getServer().getScheduler()
|
||||
.scheduleSyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Craft[] crafts = CraftManager.getInstance()
|
||||
.getCraftsInWorld(Bukkit.getWorlds().get(0));
|
||||
if (crafts == null)
|
||||
return;
|
||||
for (Craft c : crafts)
|
||||
{
|
||||
if (c.getType().getCraftName()
|
||||
.equalsIgnoreCase("mouse"))
|
||||
{
|
||||
int dx = c.getLastDX();
|
||||
/*
|
||||
* if (dx != 0)
|
||||
* System.out.println(dx);
|
||||
*/
|
||||
//int dy = c.getLastDY();
|
||||
int dz = c.getLastDZ();
|
||||
if (Bukkit
|
||||
.getWorlds()
|
||||
.get(0)
|
||||
.getBlockAt(c.getMinX(),
|
||||
c.getMinY() - 1, c.getMinZ())
|
||||
.getType() != Material.AIR
|
||||
&& (dx != 0 || dz != 0))
|
||||
UpdateMouse(null, dx * MouseSpeed, dz
|
||||
* MouseSpeed, 0, 0, "");
|
||||
c.setLastDX(0);
|
||||
/*
|
||||
* if (dz != 0)
|
||||
* System.out.println(dz);
|
||||
*/
|
||||
c.setLastDZ(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1, 1);
|
||||
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new MouseLockerPlayerListener(), this);
|
||||
}
|
||||
|
||||
public void Stop(CommandSender sender)
|
||||
{
|
||||
sender.sendMessage("§eStopping computer...");
|
||||
computer.PowerOff();
|
||||
/*
|
||||
* if (taskid != -1)
|
||||
* {
|
||||
* this.getServer().getScheduler().cancelTask(taskid); run task
|
||||
* constantly
|
||||
* taskid = -1;
|
||||
* }
|
||||
*/
|
||||
sender.sendMessage("§eComputer stopped.");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void PowerButton(CommandSender sender)
|
||||
{
|
||||
sender.sendMessage("§eStarting/stoppping computer...");
|
||||
final CommandSender s = sender;
|
||||
getServer().getScheduler().scheduleAsyncDelayedTask(this,
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (computer.PowerButton())
|
||||
{
|
||||
DoStart();
|
||||
s.sendMessage("§eComputer started.");
|
||||
} else
|
||||
s.sendMessage("§ePowerbutton pressed.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Reset(CommandSender sender)
|
||||
{
|
||||
sender.sendMessage("§eResetting computer...");
|
||||
computer.Reset();
|
||||
sender.sendMessage("§eComputer reset.");
|
||||
}
|
||||
|
||||
public void FixScreen(CommandSender sender)
|
||||
{
|
||||
sender.sendMessage("§eFixing screen...");
|
||||
computer.FixScreen();
|
||||
sender.sendMessage("§eScreen fixed.");
|
||||
}
|
||||
|
||||
public void PressKey(CommandSender sender, String key,
|
||||
String stateorduration)
|
||||
{
|
||||
//sender.sendMessage("Pressing key...");
|
||||
if (stateorduration.length() == 0)
|
||||
computer.PressKey(key, (short) 0);
|
||||
else if (stateorduration.equalsIgnoreCase("down"))
|
||||
computer.PressKey(key, (short) -1);
|
||||
else if (stateorduration.equalsIgnoreCase("up"))
|
||||
computer.PressKey(key, (short) -2);
|
||||
else
|
||||
computer.PressKey(key, Short.parseShort(stateorduration));
|
||||
//sender.sendMessage("Key pressed.");
|
||||
}
|
||||
|
||||
public void UpdateMouse(CommandSender sender, int x, int y, int z, int w,
|
||||
String mbs, boolean down)
|
||||
{
|
||||
/*
|
||||
* if (sender != null)
|
||||
* sender.sendMessage("Updating mouse...");
|
||||
*/
|
||||
if (down)
|
||||
computer.UpdateMouse(x, y, z, w, mbs);
|
||||
else
|
||||
computer.UpdateMouse(x, y, z, w, "");
|
||||
/*
|
||||
* if (sender != null)
|
||||
* sender.sendMessage("Updated mouse.");
|
||||
*/
|
||||
}
|
||||
|
||||
public void UpdateMouse(CommandSender sender, int x, int y, int z, int w,
|
||||
String mbs)
|
||||
{
|
||||
UpdateMouse(sender, x, y, z, w, mbs, true);
|
||||
UpdateMouse(sender, x, y, z, w, mbs, false);
|
||||
}
|
||||
|
||||
/*
|
||||
* public void run() { int aX = wrapped.getInt(); int aY = wrapped.getInt();
|
||||
* int aWidth = wrapped.getInt(); int aHeight = wrapped.getInt(); int asi =
|
||||
* 0;
|
||||
*
|
||||
* // ByteBuffer dbuf = ByteBuffer.allocate(2); //
|
||||
* dbuf.putShort(num); // byte[] bytes = dbuf.array(); // { 0, 1 } for (int
|
||||
* j = (int) aY; j < aHeight && j < 480; j++) { for (int i = (int) aX; i <
|
||||
* aWidth && i < 640; i++) { int x = wrapped.getInt(); if
|
||||
* (wrapped.remaining() < 4) { runningtask = false; return; } //
|
||||
* FromArgb(255, x2, x1,x) ArmorStand as; if (armorstands[asi] == null) as =
|
||||
* (ArmorStand) Bukkit .getWorlds() .get(0) .spawnEntity( new
|
||||
* Location(Bukkit.getWorlds().get(0), j * 0.1, 80f - i * 0.1, 0f),
|
||||
* EntityType.ARMOR_STAND); else as = armorstands[asi]; ItemStack stack =
|
||||
* new ItemStack(Material.LEATHER_CHESTPLATE, 1); ((LeatherArmorMeta)
|
||||
* stack.getItemMeta()).setColor(Color .fromBGR(x));
|
||||
* as.setChestplate(stack); armorstands[asi++] = as; // x += 4;
|
||||
* wrapped.get(); wrapped.get(); wrapped.get(); wrapped.get(); } for (int k
|
||||
* = 0; k < aX * 4; k++) wrapped.get(); int add = aX + aWidth - 640; if (add
|
||||
* > 0) for (int k = 0; k < add * 4; k++) wrapped.get(); } runningtask =
|
||||
* false; }
|
||||
*/
|
||||
|
||||
private void addClassPath(final URL url) throws IOException
|
||||
{
|
||||
final URLClassLoader sysloader = (URLClassLoader) ClassLoader
|
||||
.getSystemClassLoader();
|
||||
final Class<URLClassLoader> sysclass = URLClassLoader.class;
|
||||
try
|
||||
{
|
||||
final Method method = sysclass.getDeclaredMethod("addURL",
|
||||
new Class[] { URL.class });
|
||||
method.setAccessible(true);
|
||||
method.invoke(sysloader, new Object[] { url });
|
||||
} catch (final Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
throw new IOException("Error adding " + url
|
||||
+ " to system classloader");
|
||||
}
|
||||
}
|
||||
}
|
28
VirtualComputerSender.sln
Normal file
28
VirtualComputerSender.sln
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualComputerSender", "VirtualComputerSender\VirtualComputerSender.csproj", "{5EF12535-ACDF-4D60-8E32-087F5A277946}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|x64.Build.0 = Debug|x64
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|x64.ActiveCfg = Release|x64
|
||||
{5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
6
VirtualComputerSender/App.config
Normal file
6
VirtualComputerSender/App.config
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
</configuration>
|
218
VirtualComputerSender/Computer.cs
Normal file
218
VirtualComputerSender/Computer.cs
Normal file
|
@ -0,0 +1,218 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VirtualBox;
|
||||
|
||||
namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016
|
||||
{
|
||||
public class Computer
|
||||
{ //Self-note: Don't add/edit public members
|
||||
private VirtualBoxClass vbox;
|
||||
private Session session;
|
||||
public Computer()
|
||||
{
|
||||
vbox = new VirtualBoxClass();
|
||||
session = new Session();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
var machine = (IMachine)vbox.Machines.GetValue(0);
|
||||
//if (machine.State == MachineState.MachineState_PoweredOff) //2016.02.09.
|
||||
//{
|
||||
var progress = machine.LaunchVMProcess(session, "headless", "");
|
||||
progress.WaitForCompletion(100000);
|
||||
//}
|
||||
//else if (machine.State == MachineState.MachineState_Paused || machine.State == MachineState.MachineState_Running)
|
||||
//machine.LockMachine(session, LockType.LockType_Write); //2016.02.09.
|
||||
var fb = new MCFrameBuffer(session.Console.Display);
|
||||
Screen = fb.Screen; //fb.Screen is assigned on object creation
|
||||
session.Console.Display.AttachFramebuffer(0, fb);
|
||||
session.Console.Display.SetSeamlessMode(0);
|
||||
}
|
||||
|
||||
public bool PowerButton()
|
||||
{
|
||||
if (session.State != SessionState.SessionState_Locked || session.Machine == null)
|
||||
{
|
||||
Start();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
session.Console.PowerButton();
|
||||
if (session.State != SessionState.SessionState_Locked)
|
||||
Screen = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void PowerOff()
|
||||
{
|
||||
if (session.State == SessionState.SessionState_Locked)
|
||||
{
|
||||
session.Console.PowerDown().WaitForCompletion(10000);
|
||||
Screen = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (session.State == SessionState.SessionState_Locked)
|
||||
session.Console.Reset();
|
||||
}
|
||||
|
||||
//private Color[,] Screen;
|
||||
//private byte[][][] Screen;
|
||||
private volatile int[] Screen; //<-- volatile: 2016.02.20.
|
||||
|
||||
/*public byte[][][] GetScreen()
|
||||
{
|
||||
return Screen;
|
||||
}*/
|
||||
|
||||
/*public byte GetScreenPixelColor(int x, int y, int rgb)
|
||||
{
|
||||
return Screen[x][y][rgb];
|
||||
}*/
|
||||
|
||||
public int[] GetScreenPixelColors()
|
||||
{
|
||||
if (Screen == null)
|
||||
{
|
||||
Screen = new int[640 * 480];
|
||||
for (int i = 0; i < Screen.Length; i++)
|
||||
Screen[i] = Color.Black.ToArgb();
|
||||
}
|
||||
return Screen; //TO!DO: Pass events to plugin
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern uint MapVirtualKey(uint uCode, uint uMapType); //2016.02.10.
|
||||
|
||||
const uint MAPVK_VK_TO_VSC = 0x00;
|
||||
const uint MAPVK_VSC_TO_VK = 0x01;
|
||||
const uint MAPVK_VK_TO_CHAR = 0x02;
|
||||
const uint MAPVK_VSC_TO_VK_EX = 0x03;
|
||||
const uint MAPVK_VK_TO_VSC_EX = 0x04;
|
||||
|
||||
/*private bool Shift = false;
|
||||
private bool Ctrl = false;
|
||||
private bool Alt = false;*/
|
||||
|
||||
public void PressKey(string key, short durationorstate) //durationstate: 2016.02.22.
|
||||
{
|
||||
if (session.State == SessionState.SessionState_Locked)
|
||||
{
|
||||
//session.Console.Keyboard.ReleaseKeys();
|
||||
int code = 0;
|
||||
if (key == "testall")
|
||||
{
|
||||
int x = 0;
|
||||
session.Console.Keyboard.PutScancodes(new int[128].Select(i => x++).ToArray());
|
||||
return;
|
||||
}
|
||||
//switch (key.ToLower()[0])
|
||||
//switch(key.ToLower())
|
||||
//{
|
||||
//case 'a':
|
||||
//code = 65;
|
||||
//code = 31; //2016.02.09.
|
||||
//code = 1 | (int)Keys.A; //2016.02.09.
|
||||
//code = 128 | (int)Keys.A; //2016.02.10.
|
||||
//code = BitConverter.ToInt32(new byte[4] { (byte)Keys.A, 0x00, 0x00, 0x01 }, 0);
|
||||
//code = 0x41;
|
||||
//code = (int)MapVirtualKey(0x41, MAPVK_VK_TO_VSC); //SUCCESS - 2016.02.10.
|
||||
//Virtual key code taken from Kennedy.ManagedHooks project
|
||||
//Release key scan code concept taken from VirtualBox source code (KeyboardImpl.cpp:putCAD())
|
||||
//+128
|
||||
code = (int)MapVirtualKey((uint)(VirtualKeys)Enum.Parse(typeof(VirtualKeys), key, true), MAPVK_VK_TO_VSC); //2016.02.11.
|
||||
int codeShift = (int)MapVirtualKey((uint)VirtualKeys.ShiftLeft, MAPVK_VK_TO_VSC); //2016.02.22.
|
||||
int codeCtrl = (int)MapVirtualKey((uint)VirtualKeys.ControlLeft, MAPVK_VK_TO_VSC); //2016.02.22.
|
||||
int codeAlt = (int)MapVirtualKey((uint)VirtualKeys.AltLeft, MAPVK_VK_TO_VSC); //2016.02.22.
|
||||
//Console.WriteLine("Key: " + key + " - Code: " + code); //2016.02.11.
|
||||
/*bool release = true; //2016.02.11.
|
||||
if ((key.ToLower() == "shiftleft" || key.ToLower() == "shiftright"))
|
||||
{ //2016.02.11.
|
||||
if (!Shift)
|
||||
{
|
||||
Shift = true;
|
||||
release = false;
|
||||
}
|
||||
else
|
||||
Shift = false;
|
||||
}
|
||||
else if ((key.ToLower() == "controlleft" || key.ToLower() == "controlright"))
|
||||
{ //2016.02.11.
|
||||
if (!Ctrl)
|
||||
{
|
||||
Ctrl = true;
|
||||
release = false;
|
||||
}
|
||||
else
|
||||
Ctrl = false;
|
||||
}
|
||||
else if ((key.ToLower() == "altleft" || key.ToLower() == "altright"))
|
||||
{ //2016.02.11.
|
||||
if (!Alt)
|
||||
{
|
||||
Alt = true;
|
||||
release = false;
|
||||
}
|
||||
else
|
||||
Alt = false;
|
||||
}*/
|
||||
//break;
|
||||
//default:
|
||||
//break;
|
||||
//}
|
||||
//Console.WriteLine("Code. " + code);
|
||||
if (durationorstate != -2) //<-- 2016.02.22.
|
||||
session.Console.Keyboard.PutScancode(code);
|
||||
//if (release)
|
||||
if (durationorstate == 0 || durationorstate == -2) //<-- 2016.02.22.
|
||||
session.Console.Keyboard.PutScancodes(new int[] { code + 128, codeCtrl + 128, codeShift + 128, codeAlt + 128 }); //2016.02.11. - Shift, etc.: 2016.02.22.
|
||||
if (durationorstate > 0)
|
||||
{ //2016.02.22.
|
||||
Timer t = new Timer();
|
||||
t.Tick += delegate
|
||||
{
|
||||
session.Console.Keyboard.PutScancode(code + 128);
|
||||
t.Stop();
|
||||
};
|
||||
t.Interval = durationorstate;
|
||||
t.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//public void UpdateMouse(int x, int y, int z, int w, int mbs) //MouseButtonState --> int: 2016.02.12.
|
||||
public void UpdateMouse(int x, int y, int z, int w, string mbs) //int --> string: 2016.02.22.
|
||||
{
|
||||
if (session.State != SessionState.SessionState_Locked)
|
||||
return; //2016.02.27.
|
||||
int state = 0; //<-- 2016.02.22.
|
||||
if (mbs.Length > 0) //<-- 2016.02.22.
|
||||
state = (int)(MouseBS)Enum.Parse(typeof(MouseBS), mbs, true);
|
||||
session.Console.Mouse.PutMouseEvent(x, y, z, w, state);
|
||||
}
|
||||
|
||||
public void FixScreen()
|
||||
{
|
||||
session.Console.Display.SetSeamlessMode(0);
|
||||
session.Console.Display.SetVideoModeHint(0, 1, 0, 0, 0, 640, 480, 32);
|
||||
}
|
||||
|
||||
~Computer()
|
||||
{ //2016.02.09.
|
||||
if (session.State == SessionState.SessionState_Locked)
|
||||
//session.Machine.SaveState().WaitForCompletion(10000);
|
||||
session.Machine.SaveState(); //2016.02.20.
|
||||
}
|
||||
}
|
||||
}
|
59
VirtualComputerSender/Form1.Designer.cs
generated
Normal file
59
VirtualComputerSender/Form1.Designer.cs
generated
Normal file
|
@ -0,0 +1,59 @@
|
|||
namespace VirtualComputerSender
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.Color.Black;
|
||||
this.panel1.Location = new System.Drawing.Point(12, 12);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(800, 600);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(861, 662);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
}
|
||||
}
|
||||
|
32
VirtualComputerSender/Form1.cs
Normal file
32
VirtualComputerSender/Form1.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using VirtualBox;
|
||||
|
||||
namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016
|
||||
{
|
||||
public partial class Form1: Form
|
||||
{
|
||||
private static Form1 Instance;
|
||||
public Form1()
|
||||
{
|
||||
Instance = this;
|
||||
InitializeComponent();
|
||||
Screen = panel1.CreateGraphics();
|
||||
var vbox = new VirtualBoxClass();
|
||||
var session = new Session();
|
||||
var machine = (IMachine)vbox.Machines.GetValue(0);
|
||||
var progress = machine.LaunchVMProcess(session, "headless", "");
|
||||
progress.WaitForCompletion(100000);
|
||||
session.Console.Display.AttachFramebuffer(0, new NetFrameBuffer(session.Console.Display));
|
||||
}
|
||||
|
||||
public static Graphics Screen;
|
||||
}
|
||||
}
|
120
VirtualComputerSender/Form1.resx
Normal file
120
VirtualComputerSender/Form1.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
212
VirtualComputerSender/MCFrameBuffer.cs
Normal file
212
VirtualComputerSender/MCFrameBuffer.cs
Normal file
|
@ -0,0 +1,212 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using VirtualBox;
|
||||
|
||||
namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016
|
||||
{
|
||||
public class MCFrameBuffer : IFramebuffer
|
||||
{
|
||||
private IDisplay Display;
|
||||
private Timer LastFullUpdateTimer;
|
||||
private UdpClient Client;
|
||||
|
||||
public MCFrameBuffer(IDisplay display)
|
||||
{
|
||||
Display = display;
|
||||
LastFullUpdateTimer = new Timer();
|
||||
LastFullUpdateTimer.Interval = 5000; //60s --> 5s: 2016.02.20.
|
||||
LastFullUpdateTimer.Elapsed += UpdateScreen;
|
||||
Client = new UdpClient();
|
||||
Client.Connect(new IPEndPoint(IPAddress.Loopback, 5896));
|
||||
LastFullUpdateTimer.Start();
|
||||
}
|
||||
|
||||
private void UpdateScreen(object sender, EventArgs args)
|
||||
{
|
||||
Display.InvalidateAndUpdateScreen(0);
|
||||
}
|
||||
|
||||
public IntPtr Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public const uint CBitsPerPixel = 32;
|
||||
public uint BitsPerPixel
|
||||
{
|
||||
get
|
||||
{
|
||||
return CBitsPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
public uint BytesPerLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return ScreenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Height
|
||||
{
|
||||
get
|
||||
{
|
||||
Console.WriteLine("Screen height queried.");
|
||||
return ScreenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public uint HeightReduction
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public IFramebufferOverlay Overlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapFormat PixelFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return BitmapFormat.BitmapFormat_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Width
|
||||
{
|
||||
get
|
||||
{
|
||||
Console.WriteLine("Screen width queried.");
|
||||
return ScreenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public long WinId
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Array Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return new FramebufferCapabilities[] { FramebufferCapabilities.FramebufferCapabilities_UpdateImage };
|
||||
}
|
||||
}
|
||||
|
||||
public uint GetVisibleRegion(ref byte aRectangles, uint aCount)
|
||||
{
|
||||
throw new InvalidOperationException("This should not be used.");
|
||||
}
|
||||
|
||||
public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ProcessVHWACommand(ref byte aCommand)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetVisibleRegion(ref byte aRectangles, uint aCount)
|
||||
{
|
||||
}
|
||||
|
||||
public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public const int ScreenWidth = 640;
|
||||
public const int ScreenHeight = 480;
|
||||
|
||||
//public byte[][][] Screen = CreateJaggedArray<byte[][][]>(640, 480, 3);
|
||||
public volatile int[] Screen = new int[640 * 480]; //volatile: 2016.02.20.
|
||||
public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage)
|
||||
{
|
||||
//var img = aImage.Cast<byte>().ToArray();
|
||||
Task.Run(() => //<-- 2016.02.20.
|
||||
{
|
||||
var img = (byte[])aImage;
|
||||
int x = 0;
|
||||
/*if (aWidth > 600)
|
||||
Console.WriteLine("Updating screen..."); //2016.02.15.*/
|
||||
for (int j = (int)aY; j < aHeight && j < ScreenHeight; j++)
|
||||
{
|
||||
for (int i = (int)aX; i < aWidth && i < ScreenWidth; i++)
|
||||
{
|
||||
if (x + 4 > aImage.Length)
|
||||
return;
|
||||
//Screen[i][j] = Color.FromArgb(img[x + 2], img[x + 1], img[x]);
|
||||
//Screen[i][j][0] = img[x + 2];
|
||||
//Screen[i][j][1] = img[x + 1];
|
||||
//Screen[i][j][2] = img[x];
|
||||
Screen[640 * j + i] = Color.FromArgb(img[x + 2], img[x + 1], img[x]).ToArgb();
|
||||
x += 4;
|
||||
}
|
||||
x += (int)aX * 4;
|
||||
int add = ((int)(aX + aWidth) - ScreenWidth);
|
||||
if (add > 0)
|
||||
x += add * 4;
|
||||
}
|
||||
/*if (aWidth > 600)
|
||||
Console.WriteLine("Updated screen."); //2016.02.15.*/
|
||||
});
|
||||
}
|
||||
|
||||
public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
public void Notify3DEvent(uint aType, Array aData)
|
||||
{
|
||||
}
|
||||
|
||||
static T CreateJaggedArray<T>(params int[] lengths)
|
||||
{
|
||||
return (T)InitializeJaggedArray(typeof(T).GetElementType(), 0, lengths);
|
||||
}
|
||||
|
||||
static object InitializeJaggedArray(Type type, int index, int[] lengths)
|
||||
{
|
||||
Array array = Array.CreateInstance(type, lengths[index]);
|
||||
Type elementType = type.GetElementType();
|
||||
|
||||
if (elementType != null)
|
||||
{
|
||||
for (int i = 0; i < lengths[index]; i++)
|
||||
{
|
||||
array.SetValue(
|
||||
InitializeJaggedArray(elementType, index + 1, lengths), i);
|
||||
}
|
||||
//Console.WriteLine("Screen array sizes: " + array.Length + " " + ((Array)array.GetValue(0)).Length);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
||||
}
|
19
VirtualComputerSender/MouseBS.cs
Normal file
19
VirtualComputerSender/MouseBS.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VirtualComputerSender
|
||||
{
|
||||
public enum MouseBS
|
||||
{
|
||||
LeftButton = 1,
|
||||
MiddleButton = 4,
|
||||
RightButton = 2,
|
||||
WheelDown = 16,
|
||||
WheelUp = 8,
|
||||
XButton1 = 32,
|
||||
XButton2 = 64
|
||||
}
|
||||
}
|
195
VirtualComputerSender/NetFrameBuffer.cs
Normal file
195
VirtualComputerSender/NetFrameBuffer.cs
Normal file
|
@ -0,0 +1,195 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using VirtualBox;
|
||||
|
||||
namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016
|
||||
{
|
||||
public class NetFrameBuffer : IFramebuffer
|
||||
{
|
||||
private IDisplay Display;
|
||||
private Timer LastFullUpdateTimer;
|
||||
private UdpClient Client;
|
||||
|
||||
public NetFrameBuffer(IDisplay display)
|
||||
{
|
||||
//address = Marshal.AllocHGlobal(1440 * 900 * 4);
|
||||
Display = display;
|
||||
LastFullUpdateTimer = new Timer();
|
||||
LastFullUpdateTimer.Interval = 60000;
|
||||
LastFullUpdateTimer.Elapsed += UpdateScreen;
|
||||
Client = new UdpClient();
|
||||
Client.Connect(new IPEndPoint(IPAddress.Loopback, 5896));
|
||||
LastFullUpdateTimer.Start();
|
||||
}
|
||||
|
||||
private void UpdateScreen(object sender, EventArgs args)
|
||||
{
|
||||
Display.InvalidateAndUpdateScreen(0);
|
||||
}
|
||||
|
||||
public IntPtr Address
|
||||
{
|
||||
get
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public const uint CBitsPerPixel = 32;
|
||||
public uint BitsPerPixel
|
||||
{
|
||||
get
|
||||
{
|
||||
return CBitsPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
public uint BytesPerLine
|
||||
{
|
||||
get
|
||||
{
|
||||
return ScreenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return ScreenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public uint HeightReduction
|
||||
{
|
||||
get
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
public IFramebufferOverlay Overlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public BitmapFormat PixelFormat
|
||||
{
|
||||
get
|
||||
{
|
||||
return BitmapFormat.BitmapFormat_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return ScreenWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public long WinId
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Array Capabilities
|
||||
{
|
||||
get
|
||||
{
|
||||
return new FramebufferCapabilities[] { FramebufferCapabilities.FramebufferCapabilities_UpdateImage };
|
||||
}
|
||||
}
|
||||
|
||||
public uint GetVisibleRegion(ref byte aRectangles, uint aCount)
|
||||
{
|
||||
throw new InvalidOperationException("This should not be used.");
|
||||
}
|
||||
|
||||
public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight)
|
||||
{
|
||||
//throw new InvalidOperationException("This should not be used. (Only UpdateImage.)");
|
||||
}
|
||||
|
||||
public void ProcessVHWACommand(ref byte aCommand)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetVisibleRegion(ref byte aRectangles, uint aCount)
|
||||
{
|
||||
}
|
||||
|
||||
public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public const int ScreenWidth = 640;
|
||||
public const int ScreenHeight = 480;
|
||||
|
||||
private Color[,] Screen = new Color[640, 480];
|
||||
public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage)
|
||||
{
|
||||
var img = aImage.Cast<byte>().ToArray();
|
||||
int x = 0;
|
||||
//if (aImage.Length > 1152000)
|
||||
//Form1.Screen.Clear(Color.Black);
|
||||
//else
|
||||
//{
|
||||
//Display.SetSeamlessMode(1);
|
||||
/*if (aWidth == 800 && aHeight == 600)
|
||||
Display.SetVideoModeHint(0, 1, 0, 0, 0, NetFrameBuffer.ScreenWidth, NetFrameBuffer.ScreenHeight, NetFrameBuffer.CBitsPerPixel);*/
|
||||
for (int j = (int)aY; j < aHeight && j < ScreenHeight; j++)
|
||||
{
|
||||
for (int i = (int)aX; i < aWidth && i < ScreenWidth; i++)
|
||||
{
|
||||
if (x + 4 > aImage.Length)
|
||||
return;
|
||||
//Form1.Screen.FillRectangle(new SolidBrush(Color.FromArgb(255, img[x + 2], img[x + 1], img[x])), i, j, 1, 1);
|
||||
Screen[i, j] = Color.FromArgb(img[x + 2], img[x + 1], img[x]);
|
||||
x += 4;
|
||||
}
|
||||
x += (int)aX * 4;
|
||||
int add = ((int)(aX + aWidth) - ScreenWidth);
|
||||
if (add > 0)
|
||||
x += add * 4;
|
||||
}
|
||||
/*var ms = new MemoryStream();
|
||||
var bw = new BinaryWriter(ms);
|
||||
bw.Write(Convert.ToInt32(aX));
|
||||
bw.Write(Convert.ToInt32(aY));
|
||||
bw.Write(Convert.ToInt32(aWidth));
|
||||
bw.Write(Convert.ToInt32(aHeight));
|
||||
bw.Write(img);
|
||||
bw.Flush();
|
||||
Client.Send(BitConverter.GetBytes(Convert.ToInt32(ms.Length)), 4);
|
||||
Client.Send(ms.ToArray(), Convert.ToInt32(ms.Length));
|
||||
bw.Close();*/
|
||||
//}
|
||||
}
|
||||
|
||||
public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight)
|
||||
{
|
||||
}
|
||||
|
||||
public void Notify3DEvent(uint aType, Array aData)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
22
VirtualComputerSender/Program.cs
Normal file
22
VirtualComputerSender/Program.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VirtualComputerSender
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
36
VirtualComputerSender/Properties/AssemblyInfo.cs
Normal file
36
VirtualComputerSender/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("VirtualComputerSender")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("VirtualComputerSender")]
|
||||
[assembly: AssemblyCopyright("Copyright © NorbiPeti 2015-2016")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("5ef12535-acdf-4d60-8e32-087f5a277946")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
63
VirtualComputerSender/Properties/Resources.Designer.cs
generated
Normal file
63
VirtualComputerSender/Properties/Resources.Designer.cs
generated
Normal file
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VirtualComputerSender.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VirtualComputerSender.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
117
VirtualComputerSender/Properties/Resources.resx
Normal file
117
VirtualComputerSender/Properties/Resources.resx
Normal file
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
26
VirtualComputerSender/Properties/Settings.Designer.cs
generated
Normal file
26
VirtualComputerSender/Properties/Settings.Designer.cs
generated
Normal file
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace VirtualComputerSender.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
VirtualComputerSender/Properties/Settings.settings
Normal file
7
VirtualComputerSender/Properties/Settings.settings
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
159
VirtualComputerSender/VirtualComputerSender.csproj
Normal file
159
VirtualComputerSender/VirtualComputerSender.csproj
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5EF12535-ACDF-4D60-8E32-087F5A277946}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VirtualComputerSender</RootNamespace>
|
||||
<AssemblyName>VirtualComputerSender</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\TheButtonMCAutoFlairProto\Spigot server\plugins\VirtualComputer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Computer.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MCFrameBuffer.cs" />
|
||||
<Compile Include="MouseBS.cs" />
|
||||
<Compile Include="NetFrameBuffer.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="VirtualKeys.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<COMReference Include="VirtualBox">
|
||||
<Guid>{D7569351-1750-46F0-936E-BD127D5BC264}</Guid>
|
||||
<VersionMajor>1</VersionMajor>
|
||||
<VersionMinor>3</VersionMinor>
|
||||
<Lcid>0</Lcid>
|
||||
<WrapperTool>tlbimp</WrapperTool>
|
||||
<Isolated>False</Isolated>
|
||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||
</COMReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
129
VirtualComputerSender/VirtualKeys.cs
Normal file
129
VirtualComputerSender/VirtualKeys.cs
Normal file
|
@ -0,0 +1,129 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace VirtualComputerSender
|
||||
{
|
||||
internal enum VirtualKeys
|
||||
{
|
||||
Back = 0x08,
|
||||
Tab = 0x09,
|
||||
Clear = 0x0C,
|
||||
Return = 0x0D,
|
||||
|
||||
ShiftLeft = 0xA0,
|
||||
ControlLeft = 0xA2,
|
||||
ShiftRight = 0xA1,
|
||||
ControlRight = 0xA3,
|
||||
AltLeft = 0xA4,
|
||||
AltRight = 0xA5,
|
||||
|
||||
Menu = 0x12,
|
||||
Pause = 0x13,
|
||||
Capital = 0x14,
|
||||
Escape = 0x1B,
|
||||
Space = 0x20,
|
||||
Prior = 0x21,
|
||||
Next = 0x22,
|
||||
End = 0x23,
|
||||
Home = 0x24,
|
||||
Left = 0x25,
|
||||
Up = 0x26,
|
||||
Right = 0x27,
|
||||
Down = 0x28,
|
||||
Select = 0x29,
|
||||
Print = 0x2A,
|
||||
Execute = 0x2B,
|
||||
Snapshot = 0x2C,
|
||||
Insert = 0x2D,
|
||||
Delete = 0x2E,
|
||||
Help = 0x2F,
|
||||
|
||||
D0 = 0x30,
|
||||
D1 = 0x31,
|
||||
D2 = 0x32,
|
||||
D3 = 0x33,
|
||||
D4 = 0x34,
|
||||
D5 = 0x35,
|
||||
D6 = 0x36,
|
||||
D7 = 0x37,
|
||||
D8 = 0x38,
|
||||
D9 = 0x39,
|
||||
|
||||
A = 0x41,
|
||||
B = 0x42,
|
||||
C = 0x43,
|
||||
D = 0x44,
|
||||
E = 0x45,
|
||||
F = 0x46,
|
||||
G = 0x47,
|
||||
H = 0x48,
|
||||
I = 0x49,
|
||||
J = 0x4A,
|
||||
K = 0x4B,
|
||||
L = 0x4C,
|
||||
M = 0x4D,
|
||||
N = 0x4E,
|
||||
O = 0x4F,
|
||||
P = 0x50,
|
||||
Q = 0x51,
|
||||
R = 0x52,
|
||||
S = 0x53,
|
||||
T = 0x54,
|
||||
U = 0x55,
|
||||
V = 0x56,
|
||||
W = 0x57,
|
||||
X = 0x58,
|
||||
Y = 0x59,
|
||||
Z = 0x5A,
|
||||
|
||||
LWindows = 0x5B,
|
||||
RWindows = 0x5C,
|
||||
Apps = 0x5D,
|
||||
NumPad0 = 0x60,
|
||||
NumPad1 = 0x61,
|
||||
NumPad2 = 0x62,
|
||||
NumPad3 = 0x63,
|
||||
NumPad4 = 0x64,
|
||||
NumPad5 = 0x65,
|
||||
NumPad6 = 0x66,
|
||||
NumPad7 = 0x67,
|
||||
NumPad8 = 0x68,
|
||||
NumPad9 = 0x69,
|
||||
|
||||
Multiply = 0x6A,
|
||||
Add = 0x6B,
|
||||
Separator = 0x6C,
|
||||
Subtract = 0x6D,
|
||||
Decimal = 0x6E,
|
||||
Divide = 0x6F,
|
||||
F1 = 0x70,
|
||||
F2 = 0x71,
|
||||
F3 = 0x72,
|
||||
F4 = 0x73,
|
||||
F5 = 0x74,
|
||||
F6 = 0x75,
|
||||
F7 = 0x76,
|
||||
F8 = 0x77,
|
||||
F9 = 0x78,
|
||||
F10 = 0x79,
|
||||
F11 = 0x7A,
|
||||
F12 = 0x7B,
|
||||
F13 = 0x7C,
|
||||
F14 = 0x7D,
|
||||
F15 = 0x7E,
|
||||
F16 = 0x7F,
|
||||
F17 = 0x80,
|
||||
F18 = 0x81,
|
||||
F19 = 0x82,
|
||||
F20 = 0x83,
|
||||
F21 = 0x84,
|
||||
F22 = 0x85,
|
||||
F23 = 0x86,
|
||||
F24 = 0x87,
|
||||
|
||||
NumLock = 0x90,
|
||||
Scroll = 0x91,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue