forked from Lunatrius/Schematica
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'Cardinalstars/master' into dev
- Loading branch information
Showing
5 changed files
with
375 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/com/github/lunatrius/schematica/client/gui/util/GuiOrCheckBoxHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.github.lunatrius.schematica.client.gui.util; | ||
|
||
import cpw.mods.fml.client.config.GuiCheckBox; | ||
|
||
public class GuiOrCheckBoxHandler { | ||
|
||
private int checkedBoxId; | ||
private final GuiCheckBox[] boxes; | ||
|
||
// Sets up a set of check boxes that are OR'd together. First box input will be set to the starting true checkbox. | ||
public GuiOrCheckBoxHandler(GuiCheckBox... boxes) { | ||
this.boxes = boxes; | ||
checkBox(boxes[0]); | ||
} | ||
|
||
public void checkBox(GuiCheckBox boxToCheck) { | ||
checkBox(boxToCheck.id); | ||
} | ||
|
||
public void checkBox(int id) { | ||
boolean foundCheck = false; | ||
for (GuiCheckBox box : boxes) { | ||
if (box.id == id) { | ||
box.setIsChecked(true); | ||
checkedBoxId = id; | ||
foundCheck = true; | ||
} else { | ||
box.setIsChecked(false); | ||
} | ||
} | ||
if (!foundCheck) { | ||
throw new RuntimeException( | ||
"Check box passed in that doesn't exist in the handler! Check to make sure you're passing in the correct box."); | ||
} | ||
} | ||
|
||
public int getCheckedBoxId() { | ||
return checkedBoxId; | ||
} | ||
} |
Oops, something went wrong.