This commit is contained in:
Anuken
2019-10-20 14:06:43 -04:00
parent b5e9f280e6
commit 4b428c6636
9 changed files with 71 additions and 40 deletions

View File

@@ -261,7 +261,8 @@ map.invalid = Error loading map: corrupted or invalid map file.
workshop.update = Update Item workshop.update = Update Item
workshop.error = Error fetching workshop details: {0} workshop.error = Error fetching workshop details: {0}
map.publish.confirm = Are you sure you want to publish this map?\n\n[lightgray]Make sure you agree to the Workshop EULA first, or your maps will not show up! map.publish.confirm = Are you sure you want to publish this map?\n\n[lightgray]Make sure you agree to the Workshop EULA first, or your maps will not show up!
map.menu = Select what you would like to do with this map. workshop.menu = Select what you would like to do with this item.
workshop.info = Item Info
changelog = Changelog (optional): changelog = Changelog (optional):
eula = Steam EULA eula = Steam EULA
missing = This item has been deleted or moved.\n[lightgray]The workshop listing has now been automatically un-linked. missing = This item has been deleted or moved.\n[lightgray]The workshop listing has now been automatically un-linked.

View File

@@ -283,7 +283,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
/** Last progress.*/ /** Last progress.*/
public float progress; public float progress;
/** Whether construction has started for this request.*/ /** Whether construction has started for this request.*/
public boolean initialized; public boolean initialized, worldContext = true;
/** Visual scale. Used only for rendering.*/ /** Visual scale. Used only for rendering.*/
public float animScale = 0f; public float animScale = 0f;

View File

@@ -64,7 +64,7 @@ public class Schematics implements Loadable{
all.sort(); all.sort();
Core.app.post(() -> { Core.app.post(() -> {
shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 2, maxSchematicSize + padding + 2); shadowBuffer = new FrameBuffer(maxSchematicSize + padding + 8, maxSchematicSize + padding + 8);
}); });
} }
@@ -162,6 +162,7 @@ public class Schematics implements Loadable{
//draw requests //draw requests
requests.each(req -> { requests.each(req -> {
req.animScale = 1f; req.animScale = 1f;
req.worldContext = false;
req.block.drawRequestRegion(req, requests::each); req.block.drawRequestRegion(req, requests::each);
}); });
@@ -190,8 +191,11 @@ public class Schematics implements Loadable{
public void add(Schematic schematic){ public void add(Schematic schematic){
all.add(schematic); all.add(schematic);
try{ try{
write(schematic, schematicDirectory.child(Time.millis() + "." + schematicExtension)); FileHandle file = schematicDirectory.child(Time.millis() + "." + schematicExtension);
}catch(IOException e){ write(schematic, file);
schematic.file = file;
}catch(Exception e){
ui.showException(e);
Log.err(e); Log.err(e);
} }
} }
@@ -216,6 +220,8 @@ public class Schematics implements Loadable{
x2 = result.x2; x2 = result.x2;
y2 = result.y2; y2 = result.y2;
int ox = x, oy = y, ox2 = x2, oy2 = y2;
Array<Stile> tiles = new Array<>(); Array<Stile> tiles = new Array<>();
int minx = x2, miny = y2, maxx = x, maxy = y; int minx = x2, miny = y2, maxx = x, maxy = y;
@@ -247,17 +253,19 @@ public class Schematics implements Loadable{
int width = x2 - x + 1, height = y2 - y + 1; int width = x2 - x + 1, height = y2 - y + 1;
int offsetX = -x, offsetY = -y; int offsetX = -x, offsetY = -y;
for(int cx = x; cx <= x2; cx++){ IntSet counted = new IntSet();
for(int cy = y; cy <= y2; cy++){ for(int cx = ox; cx <= ox2; cx++){
Tile tile = world.tile(cx, cy); for(int cy = oy; cy <= oy2; cy++){
Tile tile = world.ltile(cx, cy);
if(tile != null && tile.entity != null){ if(tile != null && tile.entity != null && !counted.contains(tile.pos())){
int config = tile.entity.config(); int config = tile.entity.config();
if(tile.block().posConfig){ if(tile.block().posConfig){
config = Pos.get(Pos.x(config) + offsetX, Pos.y(config) + offsetY); config = Pos.get(Pos.x(config) + offsetX, Pos.y(config) + offsetY);
} }
tiles.add(new Stile(tile.block(), cx + offsetX, cy + offsetY, config, tile.rotation())); tiles.add(new Stile(tile.block(), tile.x + offsetX, tile.y + offsetY, config, tile.rotation()));
counted.add(tile.pos());
} }
} }
} }

View File

@@ -73,7 +73,7 @@ public class DesktopInput extends InputHandler{
ui.showInfoFade("$schematic.saved"); ui.showInfoFade("$schematic.saved");
ui.schematics.showInfo(lastSchematic); ui.schematics.showInfo(lastSchematic);
}); });
}).colspan(2).size(250f, 50f); }).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
}); });
}).margin(6f); }).margin(6f);
}); });
@@ -175,6 +175,7 @@ public class DesktopInput extends InputHandler{
if(mode != none){ if(mode != none){
selectRequests.clear(); selectRequests.clear();
lastSchematic = null;
} }
if(player.isShooting && !canShoot()){ if(player.isShooting && !canShoot()){

View File

@@ -194,6 +194,7 @@ public class SchematicsDialog extends FloatingDialog{
t.addImageTextButton("$schematic.shareworkshop", Icon.wikiSmall, style, t.addImageTextButton("$schematic.shareworkshop", Icon.wikiSmall, style,
() -> platform.publish(s)).marginLeft(12f); () -> platform.publish(s)).marginLeft(12f);
t.row(); t.row();
dialog.hide();
} }
t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> { t.addImageTextButton("$schematic.copy", Icon.copySmall, style, () -> {
dialog.hide(); dialog.hide();

View File

@@ -33,20 +33,20 @@ public interface Autotiler{
} }
}); });
return buildBlending(req.tile(), req.rotation, directionals); return buildBlending(req.tile(), req.rotation, directionals, req.worldContext);
} }
default int[] buildBlending(Tile tile, int rotation, BuildRequest[] directional){ default int[] buildBlending(Tile tile, int rotation, BuildRequest[] directional, boolean world){
int[] blendresult = AutotilerHolder.blendresult; int[] blendresult = AutotilerHolder.blendresult;
blendresult[0] = 0; blendresult[0] = 0;
blendresult[1] = blendresult[2] = 1; blendresult[1] = blendresult[2] = 1;
int num = int num =
(blends(tile, rotation, directional, 2) && blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 3)) ? 0 : (blends(tile, rotation, directional, 2, world) && blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 3, world)) ? 0 :
(blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 3)) ? 1 : (blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 3, world)) ? 1 :
(blends(tile, rotation, directional, 1) && blends(tile, rotation, directional, 2)) ? 2 : (blends(tile, rotation, directional, 1, world) && blends(tile, rotation, directional, 2, world)) ? 2 :
(blends(tile, rotation, directional, 3) && blends(tile, rotation, directional, 2)) ? 3 : (blends(tile, rotation, directional, 3, world) && blends(tile, rotation, directional, 2, world)) ? 3 :
blends(tile, rotation, directional, 1) ? 4 : blends(tile, rotation, directional, 1, world) ? 4 :
blends(tile, rotation, directional, 3) ? 5 : blends(tile, rotation, directional, 3, world) ? 5 :
-1; -1;
transformCase(num, blendresult); transformCase(num, blendresult);
return blendresult; return blendresult;
@@ -70,7 +70,7 @@ public interface Autotiler{
} }
} }
default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction){ default boolean blends(Tile tile, int rotation, @Nullable BuildRequest[] directional, int direction, boolean checkWorld){
int realDir = Mathf.mod(rotation - direction, 4); int realDir = Mathf.mod(rotation - direction, 4);
if(directional != null && directional[realDir] != null){ if(directional != null && directional[realDir] != null){
BuildRequest req = directional[realDir]; BuildRequest req = directional[realDir];
@@ -78,7 +78,7 @@ public interface Autotiler{
return true; return true;
} }
} }
return blends(tile, rotation, direction); return checkWorld && blends(tile, rotation, direction);
} }
default boolean blends(Tile tile, int rotation, int direction){ default boolean blends(Tile tile, int rotation, int direction){

View File

@@ -40,7 +40,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
super.onProximityUpdate(tile); super.onProximityUpdate(tile);
ConduitEntity entity = tile.entity(); ConduitEntity entity = tile.entity();
int[] bits = buildBlending(tile, tile.rotation(), null); int[] bits = buildBlending(tile, tile.rotation(), null, true);
entity.blendbits = bits[0]; entity.blendbits = bits[0];
} }

View File

@@ -94,7 +94,7 @@ public class Conveyor extends Block implements Autotiler{
super.onProximityUpdate(tile); super.onProximityUpdate(tile);
ConveyorEntity entity = tile.entity(); ConveyorEntity entity = tile.entity();
int[] bits = buildBlending(tile, tile.rotation(), null); int[] bits = buildBlending(tile, tile.rotation(), null, true);
entity.blendbits = bits[0]; entity.blendbits = bits[0];
entity.blendsclx = bits[1]; entity.blendsclx = bits[1];
entity.blendscly = bits[2]; entity.blendscly = bits[2];

View File

@@ -57,6 +57,7 @@ public class SWorkshop implements SteamUGCCallback{
/** Publish a new item and submit an update for it. /** Publish a new item and submit an update for it.
* If it is already published, redirects to its page.*/ * If it is already published, redirects to its page.*/
public void publish(Publishable p){ public void publish(Publishable p){
Log.info("publish(): " + p.steamTitle());
if(p.hasSteamID()){ if(p.hasSteamID()){
Log.info("Content already published, redirecting to ID."); Log.info("Content already published, redirecting to ID.");
viewListing(p); viewListing(p);
@@ -64,6 +65,7 @@ public class SWorkshop implements SteamUGCCallback{
} }
if(!p.prePublish()){ if(!p.prePublish()){
Log.info("Rejecting due to pre-publish.");
return; return;
} }
@@ -92,9 +94,9 @@ public class SWorkshop implements SteamUGCCallback{
if(details.getResult() == SteamResult.OK){ if(details.getResult() == SteamResult.OK){
if(details.getOwnerID().equals(SVars.user.user.getSteamID())){ if(details.getOwnerID().equals(SVars.user.user.getSteamID())){
FloatingDialog dialog = new FloatingDialog("$editor.mapinfo"); FloatingDialog dialog = new FloatingDialog("$workshop.info");
dialog.setFillParent(false); dialog.setFillParent(false);
dialog.cont.add("$map.menu").pad(20f); dialog.cont.add("$workshop.menu").pad(20f);
dialog.addCloseButton(); dialog.addCloseButton();
dialog.buttons.addImageTextButton("$view.workshop", Icon.linkSmall, () -> { dialog.buttons.addImageTextButton("$view.workshop", Icon.linkSmall, () -> {
@@ -141,6 +143,7 @@ public class SWorkshop implements SteamUGCCallback{
} }
void update(Publishable p, SteamPublishedFileID id, String changelog){ void update(Publishable p, SteamPublishedFileID id, String changelog){
Log.info("Calling update({0})", p.steamTitle());
String sid = SteamNativeHandle.getNativeHandle(id) + ""; String sid = SteamNativeHandle.getNativeHandle(id) + "";
updateItem(id, h -> { updateItem(id, h -> {
@@ -172,10 +175,11 @@ public class SWorkshop implements SteamUGCCallback{
.size(210f, 64f); .size(210f, 64f);
dialog.buttons.addImageTextButton("$ok", Icon.checkSmall, () -> { dialog.buttons.addImageTextButton("$ok", Icon.checkSmall, () -> {
Log.info("Accepted, publishing item...");
itemHandlers.add(published);
ugc.createItem(SVars.steamID, WorkshopFileType.Community); ugc.createItem(SVars.steamID, WorkshopFileType.Community);
ui.loadfrag.show("$publishing"); ui.loadfrag.show("$publishing");
dialog.hide(); dialog.hide();
itemHandlers.add(published);
}).size(170f, 64f); }).size(170f, 64f);
dialog.show(); dialog.show();
} }
@@ -187,23 +191,30 @@ public class SWorkshop implements SteamUGCCallback{
} }
void updateItem(SteamPublishedFileID publishedFileID, Consumer<SteamUGCUpdateHandle> tagger, Runnable updated){ void updateItem(SteamPublishedFileID publishedFileID, Consumer<SteamUGCUpdateHandle> tagger, Runnable updated){
SteamUGCUpdateHandle h = ugc.startItemUpdate(SVars.steamID, publishedFileID); try{
SteamUGCUpdateHandle h = ugc.startItemUpdate(SVars.steamID, publishedFileID);
Log.info("begin updateItem({0})", publishedFileID.toString());
tagger.accept(h); tagger.accept(h);
Log.info("Tagged.");
ItemUpdateInfo info = new ItemUpdateInfo(); ItemUpdateInfo info = new ItemUpdateInfo();
ui.loadfrag.setProgress(() -> { ui.loadfrag.setProgress(() -> {
ItemUpdateStatus status = ugc.getItemUpdateProgress(h, info); ItemUpdateStatus status = ugc.getItemUpdateProgress(h, info);
ui.loadfrag.setText("$" + status.name().toLowerCase()); ui.loadfrag.setText("$" + status.name().toLowerCase());
if(status == ItemUpdateStatus.Invalid){ if(status == ItemUpdateStatus.Invalid){
ui.loadfrag.setText("$done"); ui.loadfrag.setText("$done");
return 1f; return 1f;
} }
return (float)status.ordinal() / (float)ItemUpdateStatus.values().length; return (float)status.ordinal() / (float)ItemUpdateStatus.values().length;
}); });
updatedHandlers.put(publishedFileID, updated); updatedHandlers.put(publishedFileID, updated);
}catch(Throwable t){
ui.loadfrag.hide();
Log.err(t);
}
} }
@Override @Override
@@ -216,18 +227,23 @@ public class SWorkshop implements SteamUGCCallback{
Log.info("GET QUERY " + query); Log.info("GET QUERY " + query);
if(detailHandlers.containsKey(query)){ if(detailHandlers.containsKey(query)){
Log.info("Query being handled...");
if(numResultsReturned > 0){ if(numResultsReturned > 0){
Log.info("{0} q results", numResultsReturned);
Array<SteamUGCDetails> details = new Array<>(); Array<SteamUGCDetails> details = new Array<>();
for(int i = 0; i < numResultsReturned; i++){ for(int i = 0; i < numResultsReturned; i++){
details.set(i, new SteamUGCDetails()); details.add(new SteamUGCDetails());
ugc.getQueryUGCResult(query, i, details.get(i)); ugc.getQueryUGCResult(query, i, details.get(i));
} }
detailHandlers.get(query).accept(details, result); detailHandlers.get(query).accept(details, result);
}else{ }else{
Log.info("Nothing found.");
detailHandlers.get(query).accept(new Array<>(), SteamResult.FileNotFound); detailHandlers.get(query).accept(new Array<>(), SteamResult.FileNotFound);
} }
detailHandlers.remove(query); detailHandlers.remove(query);
}else{
Log.info("Query not handled.");
} }
} }
@@ -248,14 +264,18 @@ public class SWorkshop implements SteamUGCCallback{
@Override @Override
public void onCreateItem(SteamPublishedFileID publishedFileID, boolean needsToAcceptWLA, SteamResult result){ public void onCreateItem(SteamPublishedFileID publishedFileID, boolean needsToAcceptWLA, SteamResult result){
Log.info("onCreateItem(" + result + ")");
if(!itemHandlers.isEmpty()){ if(!itemHandlers.isEmpty()){
if(result == SteamResult.OK){ if(result == SteamResult.OK){
Log.info("Passing to first handler.");
itemHandlers.first().accept(publishedFileID); itemHandlers.first().accept(publishedFileID);
}else{ }else{
ui.showErrorMessage(Core.bundle.format("publish.error ", result.name())); ui.showErrorMessage(Core.bundle.format("publish.error ", result.name()));
} }
itemHandlers.remove(0); itemHandlers.remove(0);
}else{
Log.err("No handlers for createItem()");
} }
} }