Merge branch 'master' into crater

This commit is contained in:
Patrick 'Quezler' Mounier
2020-03-15 22:00:51 +01:00
21 changed files with 42 additions and 13 deletions

View File

@@ -39,6 +39,8 @@ be.check = Check for updates
schematic = Schematic schematic = Schematic
schematic.add = Save Schematic... schematic.add = Save Schematic...
schematics = Schematics schematics = Schematics
schematic.replace = A schematic by that name already exists. Replace it?
schematic.exists = A schematic by that name already exists.
schematic.import = Import Schematic... schematic.import = Import Schematic...
schematic.exportfile = Export File schematic.exportfile = Export File
schematic.importfile = Import File schematic.importfile = Import File
@@ -775,6 +777,7 @@ rules.respawntime = Respawn Time:[lightgray] (sec)
rules.wavespacing = Wave Spacing:[lightgray] (sec) rules.wavespacing = Wave Spacing:[lightgray] (sec)
rules.buildcostmultiplier = Build Cost Multiplier rules.buildcostmultiplier = Build Cost Multiplier
rules.buildspeedmultiplier = Build Speed Multiplier rules.buildspeedmultiplier = Build Speed Multiplier
rules.deconstructrefundmultiplier = Deconstruct Refund Multiplier
rules.waitForWaveToEnd = Waves Wait for Enemies rules.waitForWaveToEnd = Waves Wait for Enemies
rules.dropzoneradius = Drop Zone Radius:[lightgray] (tiles) rules.dropzoneradius = Drop Zone Radius:[lightgray] (tiles)
rules.respawns = Max respawns per wave rules.respawns = Max respawns per wave

View File

@@ -5,7 +5,7 @@ const log = function(context, obj){
var scriptName = "base.js" var scriptName = "base.js"
var modName = "none" var modName = "none"
const print = text => log(scriptName, text); const print = text => log(modName + "/" + scriptName, text);
const extendContent = function(classType, name, params){ const extendContent = function(classType, name, params){
return new JavaAdapter(classType, params, name) return new JavaAdapter(classType, params, name)

View File

@@ -1,5 +1,6 @@
package mindustry.core; package mindustry.core;
import arc.files.*;
import arc.struct.*; import arc.struct.*;
import arc.func.*; import arc.func.*;
import arc.graphics.*; import arc.graphics.*;
@@ -182,6 +183,9 @@ public class ContentLoader{
} }
if(currentMod != null){ if(currentMod != null){
content.minfo.mod = currentMod; content.minfo.mod = currentMod;
if(content.minfo.sourceFile == null){
content.minfo.sourceFile = new Fi(content.name);
}
} }
contentNameMap[content.getContentType().ordinal()].put(content.name, content); contentNameMap[content.getContentType().ordinal()].put(content.name, content);
} }

View File

@@ -44,6 +44,8 @@ public class Rules{
public float buildCostMultiplier = 1f; public float buildCostMultiplier = 1f;
/** Multiplier for building speed. */ /** Multiplier for building speed. */
public float buildSpeedMultiplier = 1f; public float buildSpeedMultiplier = 1f;
/** Multiplier for percentage of materials refunded when deconstructing */
public float deconstructRefundMultiplier = 0.5f;
/** No-build zone around enemy core radius. */ /** No-build zone around enemy core radius. */
public float enemyCoreBuildRadius = 400f; public float enemyCoreBuildRadius = 400f;
/** Radius around enemy wave drop zones.*/ /** Radius around enemy wave drop zones.*/

View File

@@ -60,16 +60,13 @@ public class IndexedRenderer implements Disposable{
updateMatrix(); updateMatrix();
program.begin(); program.bind();
texture.bind(); texture.bind();
program.setUniformMatrix4("u_projTrans", BatchShader.copyTransform(combined)); program.setUniformMatrix4("u_projTrans", BatchShader.copyTransform(combined));
program.setUniformi("u_texture", 0); program.setUniformi("u_texture", 0);
mesh.render(program, Gl.triangles, 0, vertices.length / vsize); mesh.render(program, Gl.triangles, 0, vertices.length / vsize);
program.end();
} }
public void setColor(Color color){ public void setColor(Color color){

View File

@@ -255,10 +255,19 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
if(lastSchematic == null) return; if(lastSchematic == null) return;
ui.showTextInput("$schematic.add", "$name", "", text -> { ui.showTextInput("$schematic.add", "$name", "", text -> {
lastSchematic.tags.put("name", text); Schematic replacement = schematics.all().find(s -> s.name().equals(text));
schematics.add(lastSchematic); if(replacement != null){
ui.showInfoFade("$schematic.saved"); ui.showConfirm("$confirm", "$schematic.replace", () -> {
ui.schematics.showInfo(lastSchematic); schematics.overwrite(replacement, lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(replacement);
});
}else{
lastSchematic.tags.put("name", text);
schematics.add(lastSchematic);
ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic);
}
}); });
} }

View File

@@ -91,6 +91,9 @@ public class Scripts implements Disposable{
context.evaluateString(scope, script, file, 1, null); context.evaluateString(scope, script, file, 1, null);
return true; return true;
}catch(Throwable t){ }catch(Throwable t){
if(currentMod != null){
file = currentMod.name + "/" + file;
}
log(LogLevel.err, file, "" + getError(t)); log(LogLevel.err, file, "" + getError(t));
return false; return false;
} }
@@ -124,6 +127,8 @@ public class Scripts implements Disposable{
if(!dir.exists()) return null; // Mod and folder not found if(!dir.exists()) return null; // Mod and folder not found
return loadSource(script, dir, validator); return loadSource(script, dir, validator);
} }
currentMod = required;
return loadSource(script, required.root.child("scripts"), validator); return loadSource(script, required.root.child("scripts"), validator);
} }

View File

@@ -142,6 +142,7 @@ public class CustomRulesDialog extends FloatingDialog{
check("$rules.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions); check("$rules.reactorexplosions", b -> rules.reactorExplosions = b, () -> rules.reactorExplosions);
number("$rules.buildcostmultiplier", false, f -> rules.buildCostMultiplier = f, () -> rules.buildCostMultiplier, () -> !rules.infiniteResources); number("$rules.buildcostmultiplier", false, f -> rules.buildCostMultiplier = f, () -> rules.buildCostMultiplier, () -> !rules.infiniteResources);
number("$rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier); number("$rules.buildspeedmultiplier", f -> rules.buildSpeedMultiplier = f, () -> rules.buildSpeedMultiplier);
number("$rules.deconstructrefundmultiplier", false, f -> rules.deconstructRefundMultiplier = f, () -> rules.deconstructRefundMultiplier, () -> !rules.infiniteResources);
number("$rules.blockhealthmultiplier", f -> rules.blockHealthMultiplier = f, () -> rules.blockHealthMultiplier); number("$rules.blockhealthmultiplier", f -> rules.blockHealthMultiplier = f, () -> rules.blockHealthMultiplier);
main.addButton("$configure", main.addButton("$configure",

View File

@@ -90,6 +90,13 @@ public class SchematicsDialog extends FloatingDialog{
buttons.addImageButton(Icon.pencil, style, () -> { buttons.addImageButton(Icon.pencil, style, () -> {
ui.showTextInput("$schematic.rename", "$name", s.name(), res -> { ui.showTextInput("$schematic.rename", "$name", s.name(), res -> {
Schematic replacement = schematics.all().find(other -> other.name().equals(res) && other != s);
if(replacement != null){
//renaming to an existing schematic is not allowed, as it is not clear how the tags would be merged, and which one should be removed
ui.showErrorMessage("$schematic.exists");
return;
}
s.tags.put("name", res); s.tags.put("name", res);
s.save(); s.save();
rebuildPane[0].run(); rebuildPane[0].run();

View File

@@ -252,7 +252,7 @@ public class BuildBlock extends Block{
} }
public void deconstruct(Unit builder, @Nullable TileEntity core, float amount){ public void deconstruct(Unit builder, @Nullable TileEntity core, float amount){
float deconstructMultiplier = 0.5f; float deconstructMultiplier = state.rules.deconstructRefundMultiplier;
if(cblock != null){ if(cblock != null){
ItemStack[] requirements = cblock.requirements; ItemStack[] requirements = cblock.requirements;

View File

@@ -180,9 +180,10 @@ public class DesktopLauncher extends ClientLauncher{
static void handleCrash(Throwable e){ static void handleCrash(Throwable e){
Cons<Runnable> dialog = Runnable::run; Cons<Runnable> dialog = Runnable::run;
boolean badGPU = false; boolean badGPU = false;
String total = Strings.getCauses(e).toString();
if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || if(total.contains("Couldn't create window") ||
e.getMessage().contains("OpenGL 2.0 or higher") || e.getMessage().toLowerCase().contains("pixel format") || e.getMessage().contains("GLEW"))){ total.contains("OpenGL 2.0 or higher") || total.toLowerCase().contains("pixel format") || total.contains("GLEW")){
dialog.get(() -> message( dialog.get(() -> message(
e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() : e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() :

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=69ef047313449905aff6d1390d7136f9c7cdc986 archash=31a5158c6395b7e905ba546348c98fd99ea736bb