Search in sources :

Example 1 with DisplaySettings

use of watson.DisplaySettings in project watson by totemo.

the class WatsonCommand method processCommand.

// --------------------------------------------------------------------------
/**
   * @see net.minecraft.src.ICommand#processCommand(net.minecraft.src.ICommandSender,
   *      java.lang.String[])
   */
@Override
public void processCommand(ICommandSender sender, String[] args) {
    DisplaySettings display = Controller.instance.getDisplaySettings();
    if (args.length == 0) {
        help(sender);
        return;
    } else if (args.length == 1) {
        if (args[0].equals("help")) {
            help(sender);
            return;
        } else if (args[0].equals("clear")) {
            Controller.instance.clearBlockEditSet();
            return;
        } else if (args[0].equals("ratio")) {
            Controller.instance.getBlockEditSet().getOreDB().showRatios();
            return;
        } else if (args[0].equals("servertime")) {
            ServerTime.instance.queryServerTime(true);
            return;
        }
    }
    // "/w ore [<page>]"
    if (args.length >= 1 && args[0].equals("ore")) {
        if (args.length == 1) {
            Controller.instance.getBlockEditSet().getOreDB().listDeposits(1);
            return;
        } else if (args.length == 2) {
            boolean validPage = false;
            try {
                int page = Integer.parseInt(args[1]);
                if (page > 0) {
                    validPage = true;
                    Controller.instance.getBlockEditSet().getOreDB().listDeposits(page);
                }
            } catch (NumberFormatException ex) {
            // Handled by validPage check.
            }
            if (!validPage) {
                localError(sender, "The page number should be greater than zero.");
            }
            return;
        }
    }
    // "/w pre [<count>]"
    if (args.length >= 1 && args[0].equals("pre")) {
        if (args.length == 1) {
            Controller.instance.queryPreEdits(Configuration.instance.getPreCount());
            return;
        } else if (args.length == 2) {
            boolean validCount = false;
            try {
                int count = Integer.parseInt(args[1]);
                if (count > 0) {
                    validCount = true;
                    Controller.instance.queryPreEdits(count);
                }
            } catch (NumberFormatException ex) {
            // Handled by validCount test.
            }
            if (!validCount) {
                localError(sender, "The count parameter should be a positive number of edits to fetch.");
            }
            return;
        }
    }
    // "/w post [<count>]"
    if (args.length >= 1 && args[0].equals("post")) {
        if (args.length == 1) {
            Controller.instance.queryPostEdits(Configuration.instance.getPostCount());
            return;
        } else if (args.length == 2) {
            boolean validCount = false;
            try {
                int count = Integer.parseInt(args[1]);
                if (count > 0) {
                    validCount = true;
                    Controller.instance.queryPostEdits(count);
                }
            } catch (NumberFormatException ex) {
            // Handled by validCount test.
            }
            if (!validCount) {
                localError(sender, "The count parameter should be a positive number of edits to fetch.");
            }
            return;
        }
    }
    // "display" command.
    if (args.length >= 1 && args[0].equals("display")) {
        if (args.length == 1) {
            // Toggle display.
            display.setDisplayed(!display.isDisplayed());
            return;
        } else if (args.length == 2) {
            if (args[1].equals("on")) {
                display.setDisplayed(true);
                return;
            } else if (args[1].equals("off")) {
                display.setDisplayed(false);
                return;
            }
        }
    }
    // "outline" command.
    if (args.length >= 1 && args[0].equals("outline")) {
        if (args.length == 1) {
            // Toggle display.
            display.setOutlineShown(!display.isOutlineShown());
            return;
        } else if (args.length == 2) {
            if (args[1].equals("on")) {
                display.setOutlineShown(true);
                return;
            } else if (args[1].equals("off")) {
                display.setOutlineShown(false);
                return;
            }
        }
    }
    // "/w anno" command.
    if (args.length >= 1 && args[0].equals("anno")) {
        if (args.length == 1) {
            // Toggle display.
            display.setAnnotationsShown(!display.areAnnotationsShown());
            return;
        } else if (args.length == 2) {
            if (args[1].equals("on")) {
                display.setAnnotationsShown(true);
                return;
            } else if (args[1].equals("off")) {
                display.setAnnotationsShown(false);
                return;
            }
        }
    }
    // "vector" command.
    if (args.length >= 1 && args[0].equals("vector")) {
        if (handleVectorCommand(sender, args)) {
            return;
        }
    }
    // "/w label" command.
    if (args.length >= 1 && args[0].equals("label")) {
        if (args.length == 1) {
            // Toggle display.
            display.setLabelsShown(!display.areLabelsShown());
            return;
        } else if (args.length == 2) {
            if (args[1].equals("on")) {
                display.setLabelsShown(true);
                return;
            } else if (args[1].equals("off")) {
                display.setLabelsShown(false);
                return;
            }
        }
    }
    // Ore teleport commands: /w tp [next|prev|<number>]
    if (args.length >= 1 && args[0].equals("tp")) {
        OreDB oreDB = Controller.instance.getBlockEditSet().getOreDB();
        if (args.length == 1) {
            oreDB.tpNext();
            return;
        } else if (args.length == 2) {
            if (args[1].equals("next")) {
                oreDB.tpNext();
                return;
            } else if (args[1].equals("prev")) {
                oreDB.tpPrev();
                return;
            } else {
                try {
                    oreDB.tpIndex(Integer.parseInt(args[1]));
                } catch (NumberFormatException ex) {
                    localError(sender, "The tp argument should be next, prev or an integer.");
                }
                return;
            }
        }
    }
    // "/w edits" command.
    if (args[0].equals("edits")) {
        if (args.length == 1 || (args.length == 2 && args[1].equals("list"))) {
            Controller.instance.getBlockEditSet().listEdits();
            return;
        } else if (args.length >= 3) {
            if (args[1].equals("hide") || args[1].equals("show")) {
                for (int i = 2; i < args.length; ++i) {
                    Controller.instance.getBlockEditSet().setEditVisibility(args[i], args[1].equals("show"));
                }
                return;
            } else if (args[1].equals("remove")) {
                for (int i = 2; i < args.length; ++i) {
                    Controller.instance.getBlockEditSet().removeEdits(args[i]);
                }
                return;
            }
        }
    }
    // "/w filter" command.
    if (args[0].equals("filter")) {
        Filters filters = Controller.instance.getFilters();
        if (args.length == 1 || (args.length == 2 && args[1].equals("list"))) {
            filters.list();
            return;
        } else if (args.length == 2 && args[1].equals("clear")) {
            filters.clear();
            return;
        } else if (args.length >= 3) {
            if (args[1].equals("add")) {
                for (int i = 2; i < args.length; ++i) {
                    filters.addPlayer(args[i]);
                }
                return;
            } else if (args[1].equals("remove")) {
                for (int i = 2; i < args.length; ++i) {
                    filters.removePlayer(args[i]);
                }
                return;
            }
        }
    }
    // File commands.
    if (args.length >= 2 && args[0].equals("file")) {
        if (args[1].equals("list")) {
            if (args.length == 2) {
                Controller.instance.listBlockEditFiles("*", 1);
                return;
            } else if (args.length == 3) {
                Controller.instance.listBlockEditFiles(args[2], 1);
                return;
            } else if (args.length == 4) {
                boolean validPage = false;
                try {
                    int page = Integer.parseInt(args[3]);
                    if (page > 0) {
                        validPage = true;
                        Controller.instance.listBlockEditFiles(args[2], page);
                    }
                } catch (NumberFormatException ex) {
                // Handled by validPage check.
                }
                if (!validPage) {
                    localError(sender, "The page number should be greater than zero.");
                }
                return;
            }
        } else if (args[1].equals("delete") && args.length == 3) {
            Controller.instance.deleteBlockEditFiles(args[2]);
            return;
        } else if (args[1].equals("expire") && args.length == 3) {
            Controller.instance.expireBlockEditFiles(args[2]);
            return;
        } else if (args[1].equals("load") && args.length == 3) {
            // args[2] is either a full file name or a player name.
            Controller.instance.loadBlockEditFile(args[2]);
            return;
        } else if (args[1].equals("save")) {
            if (args.length == 2) {
                Controller.instance.saveBlockEditFile(null);
                return;
            } else if (args.length == 3) {
                Controller.instance.saveBlockEditFile(args[2]);
                return;
            }
        }
    }
    // "/w config" command with parameters.
    if (args.length >= 2 && args[0].equals("config")) {
        if (handleConfigCommand(sender, args)) {
            return;
        }
    }
    // "/w config" with no parameters, direct to /w config help
    if (args.length == 1 && args[0].equals("config")) {
        String w = Configuration.instance.getWatsonPrefix();
        localOutput(sender, "Type \"/" + w + " config help\" for help with configuration options.");
        return;
    }
    // config with no parameters
    localError(sender, "Invalid command syntax.");
}
Also used : Filters(watson.db.Filters) DisplaySettings(watson.DisplaySettings) OreDB(watson.db.OreDB)

Example 2 with DisplaySettings

use of watson.DisplaySettings in project watson by totemo.

the class WatsonGuiScreen method onGuiClosed.

// initGui
// --------------------------------------------------------------------------
/**
   * @see GuiScreen#onGuiClosed()
   */
@Override
public void onGuiClosed() {
    Configuration config = Configuration.instance;
    DisplaySettings ds = Controller.instance.getDisplaySettings();
    if ((int) ds.getMinVectorLength() != (int) config.getVectorLength()) {
        config.setVectorLength((int) ds.getMinVectorLength(), true);
    }
}
Also used : Configuration(watson.Configuration) DisplaySettings(watson.DisplaySettings)

Example 3 with DisplaySettings

use of watson.DisplaySettings in project watson by totemo.

the class WatsonGuiScreen method actionPerformed.

// --------------------------------------------------------------------------
/**
   * @see GuiScreen#actionPeformed(GuiButton)
   *
   *      When a button is clicked, update the corresponding display sections
   *      and the button label.
   */
@Override
protected void actionPerformed(GuiButton button) throws IOException {
    DisplaySettings ds = Controller.instance.getDisplaySettings();
    Configuration config = Configuration.instance;
    switch(button.id) {
        case ID_CLEAR_EDITS:
            Controller.instance.clearBlockEditSet();
            break;
        case ID_SHOW_WATSON:
            ds.setDisplayed(!ds.isDisplayed());
            button.displayString = getButtonLabel(button.id);
            enableButtons();
            break;
        case ID_SHOW_VECTORS:
            ds.setVectorsShown(!ds.areVectorsShown());
            button.displayString = getButtonLabel(button.id);
            break;
        case ID_MIN_VECTOR_LENGTH:
            break;
        case ID_SHOW_LABELS:
            ds.setLabelsShown(!ds.areLabelsShown());
            button.displayString = getButtonLabel(button.id);
            break;
        case ID_LABEL_ORDER:
            config.setTimeOrderedDeposits(!config.timeOrderedDeposits());
            button.displayString = getButtonLabel(button.id);
            break;
        case ID_SHOW_ANNOTATIONS:
            ds.setAnnotationsShown(!ds.areAnnotationsShown());
            button.displayString = getButtonLabel(button.id);
            break;
        case ID_SHOW_SELECTION:
            ds.setSelectionShown(!ds.isSelectionShown());
            button.displayString = getButtonLabel(button.id);
            break;
        case ID_DONE:
            mc.displayGuiScreen(null);
            break;
    }
}
Also used : Configuration(watson.Configuration) DisplaySettings(watson.DisplaySettings)

Example 4 with DisplaySettings

use of watson.DisplaySettings in project watson by totemo.

the class BlockEditSet method drawVectors.

// --------------------------------------------------------------------------
/**
   * Draw direction vectors indicating motion of the miner.
   */
public synchronized void drawVectors() {
    DisplaySettings settings = Controller.instance.getDisplaySettings();
    if (settings.areVectorsShown()) {
        int colourIndex = 0;
        for (PlayerEditSet editsForPlayer : _playerEdits.values()) {
            editsForPlayer.drawVectors(_vectorColours[colourIndex]);
            colourIndex = (colourIndex + 1) % _vectorColours.length;
        }
    }
// if drawing
}
Also used : DisplaySettings(watson.DisplaySettings)

Example 5 with DisplaySettings

use of watson.DisplaySettings in project watson by totemo.

the class OreDB method drawDepositLabels.

// addBlockEdit
// --------------------------------------------------------------------------
/**
   * Draw a label (billboard) for each ore deposit.
   */
public void drawDepositLabels() {
    DisplaySettings settings = Controller.instance.getDisplaySettings();
    if (settings.areLabelsShown()) {
        int id = 1;
        // Draw ore deposits in descending order of importance.
        StringBuilder label = new StringBuilder();
        for (OreDeposit deposit : getOreDepositSequence()) {
            OreBlock block = deposit.getKeyOreBlock();
            if (block.getEdit().playerEditSet.isVisible()) {
                label.setLength(0);
                label.ensureCapacity(4);
                label.append(id);
                Annotation.drawBillboard(block.getLocation().getX(), block.getLocation().getY(), block.getLocation().getZ(), Configuration.instance.getBillboardBackground(), Configuration.instance.getBillboardForeground(), 0.03, label.toString());
            }
            ++id;
        }
    // for all deposits
    }
// if drawing deposit labels
}
Also used : DisplaySettings(watson.DisplaySettings)

Aggregations

DisplaySettings (watson.DisplaySettings)8 Configuration (watson.Configuration)4 Minecraft (net.minecraft.client.Minecraft)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 GuiButton (net.minecraft.client.gui.GuiButton)1 GuiOptionButton (net.minecraft.client.gui.GuiOptionButton)1 GuiResponder (net.minecraft.client.gui.GuiPageButtonList.GuiResponder)1 GuiSlider (net.minecraft.client.gui.GuiSlider)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)1 Vec3 (net.minecraft.util.Vec3)1 Filters (watson.db.Filters)1 OreDB (watson.db.OreDB)1