2017-04-22 18:14:49 +02:00
|
|
|
/*
|
|
|
|
* This file is part of Industrial Wires.
|
2018-02-28 21:06:33 +01:00
|
|
|
* Copyright (C) 2016-2018 malte0811
|
2017-04-22 18:14:49 +02:00
|
|
|
* Industrial Wires is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
* Industrial Wires is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-09-03 20:35:23 +02:00
|
|
|
package malte0811.industrialwires.controlpanel;
|
2017-04-20 20:44:08 +02:00
|
|
|
|
|
|
|
import blusunrize.immersiveengineering.api.tool.IConfigurableTool.ToolConfig;
|
|
|
|
import net.minecraft.nbt.NBTBase;
|
2018-07-30 18:41:52 +02:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2017-04-20 20:44:08 +02:00
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
//Based on IConfigurableTool in the IE API
|
|
|
|
public interface IConfigurableComponent {
|
|
|
|
/**
|
|
|
|
* Apply and store the config option on the given stack
|
|
|
|
*/
|
|
|
|
void applyConfigOption(ConfigType type, int id, NBTBase value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return a TRANSLATED name for the config option. Try to keep this short.
|
|
|
|
*/
|
|
|
|
@Nullable
|
2018-07-30 18:41:52 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2017-04-20 20:44:08 +02:00
|
|
|
String fomatConfigName(ConfigType type, int id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return a TRANSLATED name for the config option, displayed when hovering over it
|
|
|
|
*/
|
|
|
|
@Nullable
|
2018-07-30 18:41:52 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2017-04-20 20:44:08 +02:00
|
|
|
String fomatConfigDescription(ConfigType type, int id);
|
|
|
|
|
|
|
|
default StringConfig[] getStringOptions() {
|
|
|
|
return new StringConfig[0];
|
|
|
|
}
|
|
|
|
|
2018-07-30 18:41:52 +02:00
|
|
|
default RSColorConfig[] getRSChannelOptions() {
|
|
|
|
return new RSColorConfig[0];
|
2017-04-20 20:44:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
default IntConfig[] getIntegerOptions() {
|
|
|
|
return new IntConfig[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
default BoolConfig[] getBooleanOptions() {
|
|
|
|
return new BoolConfig[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
default FloatConfig[] getFloatOptions() {
|
|
|
|
return new FloatConfig[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
class UniversalConfig<T> extends ToolConfig {
|
|
|
|
public T value;
|
|
|
|
|
|
|
|
protected UniversalConfig(String name, int x, int y, T value) {
|
|
|
|
super(name, x, y);
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class BoolConfig extends UniversalConfig<Boolean> {
|
|
|
|
public BoolConfig(String name, int x, int y, Boolean value) {
|
|
|
|
super(name, x, y, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class StringConfig extends UniversalConfig<String> {
|
|
|
|
public StringConfig(String name, int x, int y, String value) {
|
|
|
|
super(name, x, y, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-30 18:41:52 +02:00
|
|
|
class RSColorConfig extends UniversalConfig<Byte> {
|
2017-05-03 18:08:52 +02:00
|
|
|
public boolean small;
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2018-07-30 18:41:52 +02:00
|
|
|
public RSColorConfig(String name, int x, int y, Byte value) {
|
2017-05-03 18:08:52 +02:00
|
|
|
this(name, x, y, value, false);
|
|
|
|
}
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2018-07-30 18:41:52 +02:00
|
|
|
public RSColorConfig(String name, int x, int y, Byte value, boolean small) {
|
2017-04-20 20:44:08 +02:00
|
|
|
super(name, x, y, value);
|
2017-05-03 18:08:52 +02:00
|
|
|
this.small = small;
|
2017-04-20 20:44:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class IntConfig extends UniversalConfig<Integer> {
|
|
|
|
public int digits;
|
|
|
|
public boolean allowNegative;
|
|
|
|
|
|
|
|
public IntConfig(String name, int x, int y, Integer value, int digits, boolean allowNegative) {
|
|
|
|
super(name, x, y, value);
|
|
|
|
this.digits = digits;
|
|
|
|
this.allowNegative = allowNegative;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FloatConfig extends UniversalConfig<Float> {
|
|
|
|
public int width;
|
|
|
|
|
|
|
|
public FloatConfig(String name, int x, int y, Float value, int width) {
|
|
|
|
super(name, x, y, value);
|
|
|
|
this.width = width;
|
|
|
|
}
|
|
|
|
}
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2017-04-20 20:44:08 +02:00
|
|
|
enum ConfigType {
|
|
|
|
BOOL,
|
|
|
|
STRING,
|
|
|
|
RS_CHANNEL,
|
|
|
|
INT,
|
|
|
|
FLOAT;
|
|
|
|
}
|
|
|
|
}
|