use of watson.Configuration 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);
}
}
use of watson.Configuration 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;
}
}
use of watson.Configuration in project watson by totemo.
the class OreDB method getOreDepositSequence.
// getMergedBlockType
// --------------------------------------------------------------------------
/**
* Return a collection of {@link OreDeposit}s in the order that they should be
* assigned 1-based numeric labels.
*
* @return a collection of {@link OreDeposit}s in the order that they should
* be assigned 1-based numeric labels.
*/
protected ArrayList<OreDeposit> getOreDepositSequence() {
Configuration config = Configuration.instance;
if (_lastTimeOrderedDeposits != config.timeOrderedDeposits()) {
_oreDepositSequenceChanged = true;
}
if (_oreDepositSequenceChanged) {
_oreDepositSequenceChanged = false;
_lastTimeOrderedDeposits = config.timeOrderedDeposits();
// Build an array of OreDeposits in decreasing order of significance.
_oreDepositSequence.clear();
for (TypedOreDB db : _db.values()) {
for (OreDeposit deposit : db.getOreDeposits()) {
_oreDepositSequence.add(deposit);
}
}
// Reorder deposits by timestamp if required by the settings.
if (config.timeOrderedDeposits()) {
_oreDepositSequence.sort(new Comparator<OreDeposit>() {
@Override
public int compare(OreDeposit o1, OreDeposit o2) {
return Long.signum(o1.getEarliestEdit().time - o2.getEarliestEdit().time);
}
});
}
}
return _oreDepositSequence;
}
use of watson.Configuration in project watson by totemo.
the class WatsonGuiScreen method initGui.
// --------------------------------------------------------------------------
/**
* @see GuiScreen#initGui()
*/
@SuppressWarnings("unchecked")
@Override
public void initGui() {
Minecraft mc = Minecraft.getMinecraft();
FontRenderer fr = mc.fontRendererObj;
_rowHeight = (int) (fr.FONT_HEIGHT * 2.75);
int startY = height / 2 - 4 * _rowHeight;
int currentRow = 0;
buttonList.clear();
buttonList.add(new GuiButton(ID_SHOW_WATSON, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_WATSON)));
buttonList.add(new GuiButton(ID_CLEAR_EDITS, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_CLEAR_EDITS)));
buttonList.add(new GuiButton(ID_SHOW_VECTORS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_VECTORS)));
GuiResponder sliderResponder = new GuiPageButtonList.GuiResponder() {
@Override
public void onTick(int id, float value) {
// Update the display when the slider slides. Save the new length in
// the configuration when the GUI closes.
DisplaySettings ds = Controller.instance.getDisplaySettings();
ds.setMinVectorLength((int) value, false);
}
@Override
public void func_175321_a(int id, boolean value) {
}
@Override
public void func_175319_a(int id, String value) {
}
};
Configuration config = Configuration.instance;
GuiSlider slider = new GuiSlider(sliderResponder, ID_MIN_VECTOR_LENGTH, width / 2 + 25, startY + currentRow++ * _rowHeight, "Min Vector Length", 0, 20, config.getVectorLength(), new GuiSlider.FormatHelper() {
@Override
public String getText(int id, String name, float value) {
return "Min Vector Length: " + Integer.toString((int) value);
}
});
buttonList.add(slider);
buttonList.add(new GuiButton(ID_SHOW_LABELS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_LABELS)));
buttonList.add(new GuiButton(ID_LABEL_ORDER, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_LABEL_ORDER)));
buttonList.add(new GuiButton(ID_SHOW_ANNOTATIONS, width / 2 - 175, startY + currentRow * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_ANNOTATIONS)));
buttonList.add(new GuiButton(ID_SHOW_SELECTION, width / 2 + 25, startY + currentRow++ * _rowHeight, 150, 20, getButtonLabel(ID_SHOW_SELECTION)));
buttonList.add(new GuiOptionButton(ID_DONE, width / 2 - 40, startY + (currentRow + 2) * _rowHeight, 80, 20, I18n.format("gui.done", new Object[0])));
enableButtons();
}
use of watson.Configuration in project watson by totemo.
the class WatsonGuiScreen method getButtonLabel.
// actionPerformed
// --------------------------------------------------------------------------
/**
* Return the label text for a toggle button, based on its ID.
*
* @param id the control ID.
* @return the label text for a toggle button, based on its ID.
*/
protected String getButtonLabel(int id) {
DisplaySettings ds = Controller.instance.getDisplaySettings();
Configuration config = Configuration.instance;
switch(id) {
case ID_CLEAR_EDITS:
return "Clear Edits";
case ID_SHOW_WATSON:
return "Watson Display: " + (ds.isDisplayed() ? "ON" : "OFF");
case ID_SHOW_VECTORS:
return "Show Vectors: " + (ds.areVectorsShown() ? "ON" : "OFF");
case ID_MIN_VECTOR_LENGTH:
// Slider uses a callback to set text.
return "";
case ID_SHOW_LABELS:
return "Show Labels: " + (ds.areLabelsShown() ? "ON" : "OFF");
case ID_LABEL_ORDER:
return "Label Order: " + (config.timeOrderedDeposits() ? "TIMESTAMPS" : "IMPORTANCE");
case ID_SHOW_ANNOTATIONS:
return "Show Annotations: " + (ds.areAnnotationsShown() ? "ON" : "OFF");
case ID_SHOW_SELECTION:
return "Show Selection: " + (ds.isSelectionShown() ? "ON" : "OFF");
default:
return "";
}
}
Aggregations