Skip to content

Commit

Permalink
smaller scale
Browse files Browse the repository at this point in the history
  • Loading branch information
sharrlotte committed Feb 12, 2025
1 parent 3f776fd commit 20a6e50
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 28 deletions.
7 changes: 4 additions & 3 deletions src/mindytool/gui/FilterDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public FilterDialog(Cons<Cons<Seq<TagData>>> tagProvider) {
}

public void show(SearchConfig searchConfig) {
scale = Vars.mobile ? 0.55f : 0.75f;
cardSize = (int) (350 * scale);
scale = Vars.mobile ? 0.5f : 0.65f;
cardSize = (int) (300 * scale);
cols = (int) Math.ceil(Core.graphics.getWidth() / (cardSize + CARD_GAP));

TagService.onUpdate(() -> show(searchConfig));
Expand Down Expand Up @@ -123,6 +123,7 @@ public void TagSelector(Table table, SearchConfig searchConfig, TagData tag) {

table.pane(card -> {
card.defaults().size(cardSize, 50);
int z = 0;

for (int i = 0; i < tag.values().size; i++) {
var value = tag.values().get(i);
Expand All @@ -144,7 +145,7 @@ public void TagSelector(Table table, SearchConfig searchConfig, TagData tag) {
.fillX()//
.margin(12);

if (++i % cols == 0) {
if (++z % cols == 0) {
card.row();
}
}
Expand Down
33 changes: 21 additions & 12 deletions src/mindytool/gui/MapDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ private void SearchBar() {
.padLeft(2)//
.padRight(2);

searchBar.button(Icon.filterSmall, () -> loadingWrapper(() -> filterDialog.show(searchConfig))).padLeft(2).padRight(2).width(60);
searchBar.button(Icon.zoomSmall, () -> loadingWrapper(() -> request.getPage(this::handleMapResult))).padLeft(2).padRight(2).width(60);
searchBar.button(Icon.filterSmall, () -> loadingWrapper(() -> filterDialog.show(searchConfig))).padLeft(2)
.padRight(2).width(60);
searchBar.button(Icon.zoomSmall, () -> loadingWrapper(() -> request.getPage(this::handleMapResult)))
.padLeft(2).padRight(2).width(60);

})//
.fillX()//
Expand Down Expand Up @@ -175,9 +177,8 @@ private Cell<ScrollPane> MapScrollContainer(Table parent) {

return parent.pane(container -> {
float sum = 0;

for (MapData mapData : mapsData) {
if (sum + Scl.scl(IMAGE_SIZE * 2) >= Math.max(Core.graphics.getHeight(), Core.graphics.getWidth())) {
if (sum + Scl.scl(IMAGE_SIZE * 2) >= Core.graphics.getWidth()) {
container.row();
sum = 0;
}
Expand All @@ -189,23 +190,27 @@ private Cell<ScrollPane> MapScrollContainer(Table parent) {
mapPreview.table(buttons -> {
buttons.center();
buttons.defaults().size(50f);
buttons.button(Icon.download, Styles.emptyi, () -> handleDownloadMap(mapData)).padLeft(2).padRight(2);
buttons.button(Icon.info, Styles.emptyi, () -> Api.findMapById(mapData.id(), infoDialog::show)).tooltip("@info.title");
buttons.button(Icon.download, Styles.emptyi, () -> handleDownloadMap(mapData)).padLeft(2)
.padRight(2);
buttons.button(Icon.info, Styles.emptyi, () -> Api.findMapById(mapData.id(), infoDialog::show))
.tooltip("@info.title");

}).growX().height(50f);

mapPreview.row();
mapPreview.stack(new MapImage(mapData.id()), new Table(mapName -> {
mapName.top();
mapName.table(Styles.black3, c -> {
Label label = c.add(mapData.name()).style(Styles.outlineLabel).color(Color.white).top().growX().width(200f - 8f).get();
Label label = c.add(mapData.name()).style(Styles.outlineLabel).color(Color.white).top()
.growX().width(200f - 8f).get();
label.setEllipsis(true);
label.setAlignment(Align.center);
}).growX().margin(1).pad(4).maxWidth(Scl.scl(200f - 8f)).padBottom(0);
})).size(200f);

mapPreview.row();
mapPreview.table(stats -> DetailStats.draw(stats, mapData.likes(), mapData.dislikes(), mapData.downloadCount())).margin(8);
mapPreview.table(stats -> DetailStats.draw(stats, mapData.likes(), mapData.dislikes(),
mapData.downloadCount())).margin(8);

}, () -> {

Expand All @@ -222,10 +227,12 @@ private Cell<ScrollPane> MapScrollContainer(Table parent) {

private void Footer() {
table(footer -> {
footer.button(Icon.left, () -> request.previousPage(this::handleMapResult)).margin(4).pad(4).width(100).disabled(request.isLoading() || request.getPage() == 0 || request.isError()).height(40);
footer.button(Icon.left, () -> request.previousPage(this::handleMapResult)).margin(4).pad(4).width(100)
.disabled(request.isLoading() || request.getPage() == 0 || request.isError()).height(40);

footer.table(Tex.buttonDisabled, table -> {
table.labelWrap(String.valueOf(request.getPage() + 1)).width(50).style(Styles.defaultLabel).labelAlign(0).center().fill();
table.labelWrap(String.valueOf(request.getPage() + 1)).width(50).style(Styles.defaultLabel)
.labelAlign(0).center().fill();
}).pad(4).height(40);

footer.button(Icon.edit, () -> {
Expand All @@ -243,9 +250,11 @@ private void Footer() {
.width(100)//
.disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);

footer.button(Icon.right, () -> request.nextPage(this::handleMapResult)).margin(4).pad(4).width(100).disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);
footer.button(Icon.right, () -> request.nextPage(this::handleMapResult)).margin(4).pad(4).width(100)
.disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);

footer.button("@upload", () -> Core.app.openURI(Config.UPLOAD_MAP_URL)).margin(4).pad(4).width(100).disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);
footer.button("@upload", () -> Core.app.openURI(Config.UPLOAD_MAP_URL)).margin(4).pad(4).width(100)
.disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);

footer.bottom();
}).expandX().fillX();
Expand Down
39 changes: 26 additions & 13 deletions src/mindytool/gui/SchematicDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
public class SchematicDialog extends BaseDialog {

private final SchematicInfoDialog infoDialog = new SchematicInfoDialog();
private final FilterDialog filterDialog = new FilterDialog((tag) -> TagService.getTag(group -> tag.get(group.schematic)));
private final FilterDialog filterDialog = new FilterDialog(
(tag) -> TagService.getTag(group -> tag.get(group.schematic)));

private Seq<SchematicData> schematicsData = new Seq<>();
private final Debouncer debouncer = new Debouncer(500, TimeUnit.MILLISECONDS);
Expand Down Expand Up @@ -143,8 +144,10 @@ private void SearchBar() {
.padLeft(2)//
.padRight(2);

searchBar.button(Icon.filterSmall, () -> loadingWrapper(() -> filterDialog.show(searchConfig))).padLeft(2).padRight(2).width(60);
searchBar.button(Icon.zoomSmall, () -> loadingWrapper(() -> request.getPage(this::handleSchematicResult))).padLeft(2).padRight(2).width(60);
searchBar.button(Icon.filterSmall, () -> loadingWrapper(() -> filterDialog.show(searchConfig))).padLeft(2)
.padRight(2).width(60);
searchBar.button(Icon.zoomSmall, () -> loadingWrapper(() -> request.getPage(this::handleSchematicResult)))
.padLeft(2).padRight(2).width(60);

}).fillX().expandX();

Expand All @@ -160,7 +163,8 @@ private void SearchBar() {
}

private Cell<TextButton> Error(Table parent, String message) {
Cell<TextButton> error = parent.button(message, Styles.nonet, () -> request.getPage(this::handleSchematicResult));
Cell<TextButton> error = parent.button(message, Styles.nonet,
() -> request.getPage(this::handleSchematicResult));

return error.center().labelAlign(0).expand().fill();
}
Expand All @@ -177,7 +181,7 @@ private Cell<ScrollPane> SchematicScrollContainer(Table parent) {
float sum = 0;

for (SchematicData schematicData : schematicsData) {
if (sum + Scl.scl(IMAGE_SIZE * 2) >= Math.max(Core.graphics.getHeight(), Core.graphics.getWidth())) {
if (sum + Scl.scl(IMAGE_SIZE * 2) >= Core.graphics.getWidth()) {
container.row();
sum = 0;
}
Expand All @@ -191,9 +195,13 @@ private Cell<ScrollPane> SchematicScrollContainer(Table parent) {
schematicPreview.table(buttons -> {
buttons.center();
buttons.defaults().size(50f);
buttons.button(Icon.copy, Styles.emptyi, () -> handleCopySchematic(schematicData)).padLeft(2).padRight(2);
buttons.button(Icon.download, Styles.emptyi, () -> handleDownloadSchematic(schematicData)).padLeft(2).padRight(2);
buttons.button(Icon.info, Styles.emptyi, () -> Api.findSchematicById(schematicData.id(), infoDialog::show)).tooltip("@info.title");
buttons.button(Icon.copy, Styles.emptyi, () -> handleCopySchematic(schematicData))
.padLeft(2).padRight(2);
buttons.button(Icon.download, Styles.emptyi, () -> handleDownloadSchematic(schematicData))
.padLeft(2).padRight(2);
buttons.button(Icon.info, Styles.emptyi,
() -> Api.findSchematicById(schematicData.id(), infoDialog::show))
.tooltip("@info.title");

}).growX().height(50f);

Expand All @@ -220,7 +228,8 @@ private Cell<ScrollPane> SchematicScrollContainer(Table parent) {
})).size(200f);

schematicPreview.row();
schematicPreview.table(stats -> DetailStats.draw(stats, schematicData.likes(), schematicData.dislikes(), schematicData.downloadCount())).margin(8);
schematicPreview.table(stats -> DetailStats.draw(stats, schematicData.likes(),
schematicData.dislikes(), schematicData.downloadCount())).margin(8);

}, () -> {
if (button[0].childrenPressed())
Expand All @@ -232,7 +241,8 @@ private Cell<ScrollPane> SchematicScrollContainer(Table parent) {
if (!state.rules.schematicsAllowed) {
ui.showInfo("@schematic.disabled");
} else {
handleDownloadSchematicData(schematicData, data -> control.input.useSchematic(Utils.readSchematic(data)));
handleDownloadSchematicData(schematicData,
data -> control.input.useSchematic(Utils.readSchematic(data)));
hide();
}
}
Expand All @@ -253,10 +263,12 @@ private Cell<ScrollPane> SchematicScrollContainer(Table parent) {

private void Footer() {
table(footer -> {
footer.button(Icon.left, () -> request.previousPage(this::handleSchematicResult)).margin(4).pad(4).width(100).disabled(request.isLoading() || request.getPage() == 0 || request.isError()).height(40);
footer.button(Icon.left, () -> request.previousPage(this::handleSchematicResult)).margin(4).pad(4)
.width(100).disabled(request.isLoading() || request.getPage() == 0 || request.isError()).height(40);

footer.table(Tex.buttonDisabled, table -> {
table.labelWrap(String.valueOf(request.getPage() + 1)).width(50).style(Styles.defaultLabel).labelAlign(0).center().fill();
table.labelWrap(String.valueOf(request.getPage() + 1)).width(50).style(Styles.defaultLabel)
.labelAlign(0).center().fill();
}).pad(4).height(40);

footer.button(Icon.edit, () -> {
Expand All @@ -280,7 +292,8 @@ private void Footer() {
.width(100)//
.disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);

footer.button("@upload", () -> Core.app.openURI(Config.UPLOAD_SCHEMATIC_URL)).margin(4).pad(4).width(100).disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);
footer.button("@upload", () -> Core.app.openURI(Config.UPLOAD_SCHEMATIC_URL)).margin(4).pad(4).width(100)
.disabled(request.isLoading() || request.hasMore() == false || request.isError()).height(40);

footer.bottom();
}).expandX().fillX();
Expand Down

0 comments on commit 20a6e50

Please sign in to comment.