+ Added Chinese translation by sadreminderwindows

+ Added "Auto Volume" option to screens
This commit is contained in:
Nicolas BARBOTIN 2018-08-27 21:18:38 +02:00
parent e41b3845d2
commit 0f00d9112b
14 changed files with 268 additions and 6 deletions

View File

@ -64,6 +64,9 @@ public class SharedProxy {
public void screenUpdateRotationInGui(Vector3i pos, BlockSide side, Rotation rot) {
}
public void screenUpdateAutoVolumeInGui(Vector3i pos, BlockSide side, boolean av) {
}
public void displaySetPadURLGui(String padURL) {
Log.error("Called SharedProxy.displaySetPadURLGui() on server side...");
}

View File

@ -225,6 +225,16 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
}
}
@Override
public void screenUpdateAutoVolumeInGui(Vector3i pos, BlockSide side, boolean av) {
if(mc.currentScreen != null && mc.currentScreen instanceof GuiScreenConfig) {
GuiScreenConfig gsc = (GuiScreenConfig) mc.currentScreen;
if(gsc.isForBlock(pos.toBlock(), side))
gsc.updateAutoVolume(av);
}
}
@Override
public void displaySetPadURLGui(String padURL) {
mc.displayGuiScreen(new GuiSetURL2(padURL));

View File

@ -109,6 +109,9 @@ public class GuiScreenConfig extends WDScreen {
@FillControl
private CheckBox cbLockRatio;
@FillControl
private CheckBox cbAutoVolume;
private CheckBox[] friendBoxes;
private CheckBox[] otherBoxes;
@ -150,6 +153,7 @@ public class GuiScreenConfig extends WDScreen {
//Hopefully upgrades have been synchronized...
ugUpgrades.setUpgrades(scr.upgrades);
cbAutoVolume.setChecked(scr.autoVolume);
}
if(owner == null)
@ -304,7 +308,8 @@ public class GuiScreenConfig extends WDScreen {
} catch(NumberFormatException ex) {
cbLockRatio.setChecked(false);
}
}
} else if(ev.getSource() == cbAutoVolume)
WebDisplays.NET_HANDLER.sendToServer(SMessageScreenCtrl.autoVol(tes, side, ev.isChecked()));
}
@GuiSubscribe
@ -457,6 +462,7 @@ public class GuiScreenConfig extends WDScreen {
flag = (myRights & ScreenRights.MANAGE_UPGRADES) == 0;
ugUpgrades.setDisabled(flag);
cbAutoVolume.setDisabled(flag);
}
public void updateResolution(Vector2i res) {
@ -471,6 +477,10 @@ public class GuiScreenConfig extends WDScreen {
updateRotationStr();
}
public void updateAutoVolume(boolean av) {
cbAutoVolume.setChecked(av);
}
@Override
public boolean isForBlock(BlockPos bp, BlockSide side) {
return bp.equals(tes.getPos()) && side == this.side;

View File

@ -16,6 +16,7 @@ import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.gui.controls.Container;
import net.montoyo.wd.client.gui.controls.Control;
import net.montoyo.wd.client.gui.controls.Event;
import net.montoyo.wd.client.gui.controls.List;
import net.montoyo.wd.client.gui.loading.FillControl;
import net.montoyo.wd.client.gui.loading.GuiLoader;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
@ -342,6 +343,10 @@ public abstract class WDScreen extends GuiScreen {
renderToolTip(is, x, y); //Since it's protected...
}
public void drawTooltip(java.util.List<String> lines, int x, int y) {
drawHoveringText(lines, x, y, fontRenderer); //This is also protected...
}
public void requirePostDraw(Control ctrl) {
if(!postDrawList.contains(ctrl))
postDrawList.add(ctrl);

View File

@ -10,6 +10,8 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.util.ResourceLocation;
import net.montoyo.wd.client.gui.loading.JsonOWrapper;
import java.util.Arrays;
public class CheckBox extends BasicControl {
private static final ResourceLocation texUnchecked = new ResourceLocation("webdisplays", "textures/gui/checkbox.png");
@ -35,6 +37,7 @@ public class CheckBox extends BasicControl {
private String label;
private int labelW;
private boolean checked;
private java.util.List<String> tooltip;
public CheckBox() {
label = "";
@ -116,6 +119,18 @@ public class CheckBox extends BasicControl {
label = tr(json.getString("label", ""));
labelW = font.getStringWidth(label);
checked = json.getBool("checked", false);
String tt = tr(json.getString("tooltip", ""));
if(!tt.isEmpty()) {
tooltip = Arrays.asList(tt.split("\\\\n"));
parent.requirePostDraw(this);
}
}
@Override
public void postDraw(int mouseX, int mouseY, float ptt) {
if(tooltip != null && !disabled && mouseX >= x && mouseX <= x + WIDTH + 2 + labelW && mouseY >= y && mouseY < y + HEIGHT)
parent.drawTooltip(tooltip, mouseX, mouseY);
}
}

View File

@ -10,7 +10,7 @@ public abstract class ScreenRights {
public static final int CLICK = 2; //Click AND type
public static final int MANAGE_FRIEND_LIST = 4;
public static final int MANAGE_OTHER_RIGHTS = 8;
public static final int MANAGE_UPGRADES = 16; //Manage upgrades AND peripherals
public static final int MANAGE_UPGRADES = 16; //Manage upgrades AND peripherals AND autoVolume
public static final int CHANGE_RESOLUTION = 32; //Change resolution AND rotation
public static final int NONE = 0;

View File

@ -60,6 +60,7 @@ public class TileEntityScreen extends TileEntity {
public EntityPlayer laserUser;
public final Vector2i lastMousePos = new Vector2i();
public NibbleArray redstoneStatus; //null on client
public boolean autoVolume = true;
public static Screen deserialize(NBTTagCompound tag) {
Screen ret = new Screen();
@ -104,6 +105,9 @@ public class TileEntityScreen extends TileEntity {
for(int i = 0; i < upgrades.tagCount(); i++)
ret.upgrades.add(new ItemStack(upgrades.getCompoundTagAt(i)));
if(tag.hasKey("AutoVolume"))
ret.autoVolume = tag.getBoolean("AutoVolume");
return ret;
}
@ -142,6 +146,7 @@ public class TileEntityScreen extends TileEntity {
list.appendTag(is.writeToNBT(new NBTTagCompound()));
tag.setTag("Upgrades", list);
tag.setBoolean("AutoVolume", autoVolume);
return tag;
}
@ -644,7 +649,7 @@ public class TileEntityScreen extends TileEntity {
int fracPart = 0;
for(Screen scr: screens) {
if(scr.videoType != null && scr.browser != null && !scr.browser.isPageLoading()) {
if(scr.autoVolume && scr.videoType != null && scr.browser != null && !scr.browser.isPageLoading()) {
if(needsComputation) {
float dist = (float) Math.sqrt(d);
float vol;
@ -1035,6 +1040,23 @@ public class TileEntityScreen extends TileEntity {
WebDisplays.NET_HANDLER.sendToAllAround(CMessageScreenUpdate.js(this, side, code), point());
}
public void setAutoVolume(BlockSide side, boolean av) {
Screen scr = getScreen(side);
if(scr == null) {
Log.error("Trying to toggle auto-volume on invalid screen (side %s)", side.toString());
return;
}
scr.autoVolume = av;
if(world.isRemote)
WebDisplays.PROXY.screenUpdateAutoVolumeInGui(new Vector3i(pos), side, av);
else {
WebDisplays.NET_HANDLER.sendToAllAround(CMessageScreenUpdate.autoVolume(this, side, av), point());
markDirty();
}
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState) {
if(oldState.getBlock() != WebDisplays.INSTANCE.blockScreen || newState.getBlock() != WebDisplays.INSTANCE.blockScreen)

View File

@ -32,6 +32,7 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
public static final int UPDATE_OWNER = 7;
public static final int UPDATE_ROTATION = 8;
public static final int UPDATE_RUN_JS = 9;
public static final int UPDATE_AUTO_VOL = 10;
public static final int MOUSE_CLICK = 0;
public static final int MOUSE_UP = 1;
@ -48,6 +49,7 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
private int redstoneLevel;
private NameUUIDPair owner;
private Rotation rotation;
private boolean autoVolume;
public CMessageScreenUpdate() {
}
@ -155,6 +157,16 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
return ret;
}
public static CMessageScreenUpdate autoVolume(TileEntityScreen tes, BlockSide side, boolean av) {
CMessageScreenUpdate ret = new CMessageScreenUpdate();
ret.pos = new Vector3i(tes.getPos());
ret.side = side;
ret.action = UPDATE_AUTO_VOL;
ret.autoVolume = av;
return ret;
}
@Override
public void fromBytes(ByteBuf buf) {
pos = new Vector3i(buf);
@ -182,6 +194,8 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
owner = new NameUUIDPair(buf);
else if(action == UPDATE_ROTATION)
rotation = Rotation.values()[buf.readByte() & 3];
else if(action == UPDATE_AUTO_VOL)
autoVolume = buf.readBoolean();
}
@Override
@ -211,6 +225,8 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
owner.writeTo(buf);
else if(action == UPDATE_ROTATION)
buf.writeByte(rotation.ordinal());
else if(action == UPDATE_AUTO_VOL)
buf.writeBoolean(autoVolume);
}
@Override
@ -251,6 +267,8 @@ public class CMessageScreenUpdate implements IMessage, Runnable {
scr.owner = owner;
} else if(action == UPDATE_ROTATION)
tes.setRotation(side, rotation);
else if(action == UPDATE_AUTO_VOL)
tes.setAutoVolume(side, autoVolume);
else
Log.warning("Caught invalid CMessageScreenUpdate with action ID %d", action);
}

View File

@ -45,6 +45,7 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
public static final int CTRL_JS_REQUEST = 11;
public static final int CTRL_SET_ROTATION = 12;
public static final int CTRL_SET_URL_REMOTE = 13;
public static final int CTRL_SET_AUTO_VOL = 14;
private int ctrl;
private int dim;
@ -64,6 +65,7 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
private Object[] jsReqData;
private Rotation rotation;
private Vector3i remoteLoc;
private boolean autoVol;
public SMessageScreenCtrl() {
}
@ -164,6 +166,17 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
return ret;
}
public static SMessageScreenCtrl autoVol(TileEntityScreen tes, BlockSide side, boolean av) {
SMessageScreenCtrl ret = new SMessageScreenCtrl();
ret.ctrl = CTRL_SET_AUTO_VOL;
ret.pos = new Vector3i(tes.getPos());
ret.dim = tes.getWorld().provider.getDimension();
ret.side = side;
ret.autoVol = av;
return ret;
}
private static boolean isVec2Ctrl(int msg) {
return msg == CTRL_SET_RESOLUTION || msg == CTRL_LASER_DOWN || msg == CTRL_LASER_MOVE;
}
@ -204,7 +217,8 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
else if(ctrl == CTRL_SET_URL_REMOTE) {
url = ByteBufUtils.readUTF8String(buf);
remoteLoc = new Vector3i(buf);
}
} else if(ctrl == CTRL_SET_AUTO_VOL)
autoVol = buf.readBoolean();
}
@Override
@ -241,7 +255,8 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
else if(ctrl == CTRL_SET_URL_REMOTE) {
ByteBufUtils.writeUTF8String(buf, url);
remoteLoc.writeTo(buf);
}
} else if(ctrl == CTRL_SET_AUTO_VOL)
buf.writeBoolean(autoVol);
}
@Override
@ -336,6 +351,9 @@ public class SMessageScreenCtrl implements IMessage, Runnable {
} else if(ctrl == CTRL_SET_ROTATION) {
checkPermission(tes, ScreenRights.CHANGE_RESOLUTION);
tes.setRotation(side, rotation);
} else if(ctrl == CTRL_SET_AUTO_VOL) {
checkPermission(tes, ScreenRights.MANAGE_UPGRADES); //because why not
tes.setAutoVolume(side, autoVol);
} else
Log.warning("Caught SMessageScreenCtrl with invalid control ID %d from player %s (UUID %s)", ctrl, player.getName(), player.getGameProfile().getId().toString());
}

View File

@ -200,6 +200,14 @@
"x": 260,
"y": 129,
"width": 84
},
{
"type": "CheckBox",
"name": "cbAutoVolume",
"x": 257,
"y": 150,
"label": "$webdisplays.gui.screencfg.autovol",
"tooltip": "$webdisplays.gui.screencfg.avwarning"
}
],
"center": true

View File

@ -73,6 +73,8 @@ webdisplays.gui.screencfg.rot90=90°
webdisplays.gui.screencfg.rot180=180°
webdisplays.gui.screencfg.rot270=270°
webdisplays.gui.screencfg.lockratio=Lock ratio
webdisplays.gui.screencfg.autovol=Auto Volume
webdisplays.gui.screencfg.avwarning=§cCareful!\nAuto volume only works on YouTube\nvideos, and if enabled in client config!
webdisplays.linker.selectScreen=Right click on a screen
webdisplays.linker.selectPeripheral=Right click on a peripheral
webdisplays.linker.posInfo=Screen pos: %d %d %d

View File

@ -73,6 +73,8 @@ webdisplays.gui.screencfg.rot90=90°
webdisplays.gui.screencfg.rot180=180°
webdisplays.gui.screencfg.rot270=270°
webdisplays.gui.screencfg.lockratio=Verrouiller le ratio
webdisplays.gui.screencfg.autovol=Volume Auto
webdisplays.gui.screencfg.avwarning=§cAttention !\nLe volume auto ne fonctionne\nque sur les vidéos YouTube, et\nsi il a été activé dans la config !
webdisplays.linker.selectScreen=Cliquez droit sur un écran
webdisplays.linker.selectPeripheral=Cliquez droit sur un périphérique
webdisplays.linker.posInfo=Pos. écran : %d %d %d

View File

@ -0,0 +1,149 @@
itemGroup.webdisplays=§5内置网页浏览器
tile.webdisplays.screen.name=网页屏幕方块
tile.webdisplays.peripheral.name=外部设备
tile.webdisplays.peripheral.keyboard.name=键盘
tile.webdisplays.peripheral.remotectrl.name=网页输入器
tile.webdisplays.peripheral.ccinterface.name=ComputerCraft接口
tile.webdisplays.peripheral.cointerface.name=OpenComputers接口
tile.webdisplays.peripheral.redstonectrl.name=红石控制器
tile.webdisplays.peripheral.server.name=服务器方块
item.webdisplays.screencfg.name=屏幕配置器
item.webdisplays.ownerthief.name=屏幕所有权给予器[管理员物品]
item.webdisplays.linker.name=连接工具
item.webdisplays.craftcomp.name=制作材料
item.webdisplays.craftcomp.stonekey.name=石头按钮
item.webdisplays.craftcomp.upgrade.name=空白升级组件
item.webdisplays.craftcomp.peripheral.name=外部设备材料
item.webdisplays.craftcomp.batcell.name=电池
item.webdisplays.craftcomp.batpack.name=电池组
item.webdisplays.craftcomp.laserdiode.name=650纳米激光二极管
item.webdisplays.craftcomp.backlight.name=屏幕背景
item.webdisplays.craftcomp.extcard.name=扩充卡片
item.webdisplays.craftcomp.badextcard.name=损坏的扩充卡片
item.webdisplays.minepad.name=掌上电脑
item.webdisplays.minepad2.name=第二代掌上电脑
item.webdisplays.upgrade.name=屏幕升级组件
item.webdisplays.upgrade.lasermouse.name=激光笔模块
item.webdisplays.upgrade.redinput.name=红石输入模块
item.webdisplays.upgrade.redoutput.name=红石输出模块
item.webdisplays.upgrade.gps.name=GPS模块
item.webdisplays.laserpointer.name=激光笔
item.webdisplays.advicon.name=进度图标
item.webdisplays.advicon.wd.name=内置网页浏览器
item.webdisplays.advicon.brokenpad.name=损坏的掌上电脑
item.webdisplays.advicon.pigeon.name=鸽子
item.webdisplays.wiki=点击"F1"来打开维基百科
webdisplays.message.tooSmall=这个屏幕太小了!最小尺寸是2x2.
webdisplays.message.tooBig=这个屏幕太大了!最大尺寸是%dx%d.
webdisplays.message.invalid=这个结构无效;你在看着坐标%s.
webdisplays.message.turnOn=你需要先打开这个屏幕!
webdisplays.message.screenSet=屏幕已设置!现在应将这个物品给新的拥有者...
webdisplays.message.newOwner=你现在是这个屏幕的拥有者!
webdisplays.message.restrictions=你不能做这件事 :(
webdisplays.message.peripheral=这不是一个外部设备!
webdisplays.message.linked=已连接!
webdisplays.message.linkError=连接失败 :( 请检查日志...
webdisplays.message.notAScreen=请先右击屏幕...
webdisplays.message.screenSet2=屏幕已设置!现在右击一个外部设备...
webdisplays.message.chunkUnloaded=放置在这个区块的屏幕未开启!
webdisplays.message.notLinked=这个外部设备还未连接.
webdisplays.message.missingCC=ComputerCraft不可用.
webdisplays.message.missingOC=OpenComputers不可用.
webdisplays.message.upgradeError=升级组件安装失败 :( 请检查日志...
webdisplays.message.upgradeOk=升级组件已安装!
webdisplays.message.linkAbort=连接器复位
webdisplays.message.noMiniserv=服务器方块在这个服务器不可用
webdisplays.message.otDisabled=屏幕所有权给予者在这个服务器不可用
webdisplays.gui.screencfg.owner=屏幕拥有者:
webdisplays.gui.screencfg.friends=朋友:
webdisplays.gui.screencfg.permissions=权限:
webdisplays.gui.screencfg.seturl=修改网址
webdisplays.gui.screencfg.click=点击和输入
webdisplays.gui.screencfg.friendlist=管理朋友
webdisplays.gui.screencfg.otherrights=管理其他人
webdisplays.gui.screencfg.mupgrades=安装升级组件和连接
webdisplays.gui.screencfg.mres=改变分辨率
webdisplays.gui.screencfg.others=其他人
webdisplays.gui.screencfg.upgrades=升级组件:
webdisplays.gui.screencfg.resolution=当前分辨率:
webdisplays.gui.screencfg.setres=设置分辨率
webdisplays.gui.screencfg.rotation=角度
webdisplays.gui.screencfg.rot0=0°
webdisplays.gui.screencfg.rot90=90°
webdisplays.gui.screencfg.rot180=180°
webdisplays.gui.screencfg.rot270=270°
webdisplays.gui.screencfg.lockratio=锁定分辨率比例
webdisplays.linker.selectScreen=右击一个屏幕
webdisplays.linker.selectPeripheral=右击一个外部设备
webdisplays.linker.posInfo=屏幕位置:%d %d %d
webdisplays.linker.sideInfo=地址:%s
webdisplays.gui.seturl.url=网址:
webdisplays.gui.seturl.ok=确定
webdisplays.gui.seturl.cancel=取消
webdisplays.gui.seturl.shutdown=停止
webdisplays.minepad.turnon=潜行并右击来打开
webdisplays.minepad2.info=不退款!
webdisplays.extcard.cantcraft1=你知道的还不够多.
webdisplays.extcard.cantcraft2=你不能制作这个物品.
webdisplays.extcard.bad=有人制作扩展卡片失败了
webdisplays.gui.keyboard.hooked=已连接至你的键盘.请按ESC离开界面.
webdisplays.gui.keyboard.warning1=警告!你输入的数据都将以纯文本形式发送到服务器.
webdisplays.gui.keyboard.warning2=这意味着任何人都可以知道你在输入什么.
webdisplays.gui.keyboard.warning3=永远都不要用这个键盘输入你的密码.
webdisplays.gui.keyboard.gotcha=被我耍到啦
advancements.webdisplays.root.title=内置网页浏览器
advancements.webdisplays.root.description=内置网页浏览器Mod
advancements.webdisplays.screen.title=互联网是...
advancements.webdisplays.screen.description=制作你第一个屏幕方块
advancements.webdisplays.minepad.title=这可是个革命
advancements.webdisplays.minepad.description=你得到了最新的科技:掌上电脑
advancements.webdisplays.padbreak.title=逆向工程
advancements.webdisplays.padbreak.description=这些东西易碎!不要为了得到升级组件材料而让掌上电脑从高空坠落
advancements.webdisplays.minepad2.title=鸽子
advancements.webdisplays.minepad2.description=制作第二代掌上电脑.看,我知道它有多贵,但这意味着它比任何东西都好,对吧?...对吧?
advancements.webdisplays.linkperipheral.title=这是无线的!
advancements.webdisplays.linkperipheral.description=连接外部设备到屏幕
advancements.webdisplays.keyboardcat.title=可恶的猫
advancements.webdisplays.keyboardcat.description=让一只猫踩过你的键盘
advancements.webdisplays.upgrade.title=不仅只是一个屏幕
advancements.webdisplays.upgrade.description=安装了你的第一个升级组件
advancements.webdisplays.laser.title=不要对着眼睛
advancements.webdisplays.laser.description=制作激光笔!
webdisplays.side.bottom=底部
webdisplays.side.top=顶部
webdisplays.side.north=北方
webdisplays.side.south=南方
webdisplays.side.west=西方
webdisplays.side.east=东方
webdisplays.server.info=如果你需要帮助请输入"help".
webdisplays.server.unknowncmd=未知指令.
webdisplays.server.error=内部错误.请检查日志.
webdisplays.server.error2=内部错误%d.请检查日志.
webdisplays.server.argerror=未识别的参数.
webdisplays.server.queryerr=查询错误,尝试输入"reconnect".
webdisplays.server.errowner=只有拥有者才可以访问.
webdisplays.server.timeout=查询超时.请检查日志.
webdisplays.server.ownername=拥有者名称:%s
webdisplays.server.owneruuid=拥有者UUID:
webdisplays.server.quota=%s/%s已使用
webdisplays.server.fnamearg=丢失文件名参数
webdisplays.server.nameerr=无效的文件名
webdisplays.server.urlcopied=复制网址到你的剪切板.
webdisplays.server.notfound=文件未找到
webdisplays.server.upload.info=选择一个文件来上传
webdisplays.server.upload.parent=[父目录]
webdisplays.server.upload.uploading=上传中...
webdisplays.server.upload.done=完成
webdisplays.server.upload.exists=错误:文件不存在
webdisplays.server.upload.quota=错误:文件过大
webdisplays.server.help.help=显示这段文本
webdisplays.server.help.clear=清空这个屏幕
webdisplays.server.help.exit=离开这个控制台
webdisplays.server.help.access=§k无帮助文件
webdisplays.server.help.owner=显示服务器的拥有者
webdisplays.server.help.quota=显示存储空间
webdisplays.server.help.ls=显示这个服务器的文件
webdisplays.server.help.url=复制一个文件网址到你的剪切板
webdisplays.server.help.upload=打开上传向导
webdisplays.server.help.rm=删除一个文件
webdisplays.server.help.reconnect=重新连接到服务器[调试中]

View File

@ -8,7 +8,7 @@
"url": "https://montoyo.net/wd2.php",
"updateUrl": "",
"authorList": [ "montoyo" ],
"credits": "",
"credits": "Thanks to sadreminderwindows for the Chinese translation",
"logoFile": "",
"screenshots": [],
"dependencies": []