All web version bugs fixed

This commit is contained in:
Anuken
2018-07-31 12:57:34 -04:00
parent cc23378758
commit f3b976bdd1
16 changed files with 29 additions and 35 deletions

View File

@@ -138,8 +138,6 @@ public class Vars{
String code = stra[i];
if(code.contains("_")){
locales[i] = new Locale(code.split("_")[0], code.split("_")[1]);
}else if(code.contains("-")){
locales[i] = new Locale(code.split("-")[0], code.split("-")[1]);
}else{
locales[i] = new Locale(code);
}

View File

@@ -43,10 +43,6 @@ public abstract class Platform {
public String getLocaleName(Locale locale){
return locale.toString();
}
/**Whether joining games is supported.*/
public boolean canJoinGame(){
return true;
}
/**Whether debug mode is enabled.*/
public boolean isDebug(){return false;}
/**Must be a base64 string 8 bytes in length.*/

View File

@@ -214,7 +214,7 @@ public class Saves{
}
public boolean isAutosave(){
return Settings.getBool("save-" + index + "-autosave", !gwt);
return Settings.getBool("save-" + index + "-autosave", true);
}
public void setAutosave(boolean save){

View File

@@ -62,7 +62,7 @@ public class FogRenderer implements Disposable{
}
}
pixelBuffer = ByteBuffer.allocateDirect(world.width() * world.height() * 3);
pixelBuffer = ByteBuffer.allocateDirect(world.width() * world.height() * 4);
dirty = true;
});
@@ -79,7 +79,7 @@ public class FogRenderer implements Disposable{
buffer.begin();
pixelBuffer.position(0);
Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1);
Gdx.gl.glReadPixels(padding, padding, world.width(), world.height(), GL20.GL_RGB, GL20.GL_UNSIGNED_BYTE, pixelBuffer);
Gdx.gl.glReadPixels(padding, padding, world.width(), world.height(), GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer);
pixelBuffer.position(0);
for(int i = 0; i < world.width() * world.height(); i++){
@@ -87,7 +87,7 @@ public class FogRenderer implements Disposable{
if(r != 0){
world.tile(i).setVisibility((byte)1);
}
pixelBuffer.position(pixelBuffer.position() + 2);
pixelBuffer.position(pixelBuffer.position() + 3);
}
buffer.end();
}

View File

@@ -49,9 +49,7 @@ public class SaveIO{
public static void loadFromSlot(int slot){
if(gwt){
String string = Settings.getString("save-" + slot + "-data", "");
ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decode(string));
load(stream);
load(getSlotStream(slot));
}else{
load(fileFor(slot));
}
@@ -113,14 +111,14 @@ public class SaveIO{
}
public static void write(FileHandle file){
write(file.write(false));
write(new DeflaterOutputStream(file.write(false)));
}
public static void write(OutputStream os){
DataOutputStream stream;
try{
stream = new DataOutputStream(new DeflaterOutputStream(os));
stream = new DataOutputStream(os);
getVersion().write(stream);
stream.close();
}catch(Exception e){

View File

@@ -38,6 +38,14 @@ public class Net{
private static IntMap<StreamBuilder> streams = new IntMap<>();
public static boolean hasClient(){
return clientProvider != null;
}
public static boolean hasServer(){
return serverProvider != null;
}
/**
* Display a network error.
*/

View File

@@ -56,7 +56,7 @@ public class PausedDialog extends FloatingDialog{
if(!gwt){
ui.host.show();
}else{
ui.showInfo("$text.host.web");
ui.showInfo("$text.web.unsupported");
}
}).disabled(b -> Net.active());

View File

@@ -109,7 +109,9 @@ public class HudFragment extends Fragment{
t.label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10);
t.label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
t.row();
t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
if(Net.hasClient()){
t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
}
}).size(-1).visible(() -> Settings.getBool("fps")).get();
//make wave box appear below rest of menu

View File

@@ -153,11 +153,11 @@ public class MenuFragment extends Fragment{
dialog.content().row();
dialog.content().add(new MenuButton("icon-add", "$text.joingame", () -> {
if(Platform.instance.canJoinGame()){
if(!gwt){
ui.join.show();
dialog.hide();
}else{
ui.showInfo("$text.multiplayer.web");
ui.showInfo("$text.web.unsupported");
}
}));