Skip to content

Commit

Permalink
C: 单位工厂-X 完成
Browse files Browse the repository at this point in the history
  • Loading branch information
MinRi2 committed Dec 29, 2024
1 parent e3f3832 commit 5fd2f11
Showing 1 changed file with 43 additions and 33 deletions.
76 changes: 43 additions & 33 deletions core/src/mindustryX/features/ui/UnitFactoryDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,52 +195,58 @@ private void rebuild(){
// 等table分配大小后重构
Core.app.post(this::rebuildUnitSelection);

Cell<?> selectionCell = main.add(selection);
Table rightTable = new Table();

if(Core.graphics.isPortrait()){
main.row();
}
rightTable.top();
rightTable.defaults().growX();

Cell<?> mainCell = main.table(null, rightTable -> {
rightTable.top();
rightTable.defaults().growX();
rightTable.add(infoTable).row();

rightTable.add(infoTable).row();
rightTable.defaults().padTop(12f);

rightTable.add(posTable).row();
rightTable.add(countTable).row();
rightTable.table(randDstTable -> {
randDstTable.add("生成范围:");
randDstTable.field(Strings.autoFixed(unitRandDst, 3), text -> {
unitRandDst = Float.parseFloat(text);
}).valid(Strings::canParsePositiveFloat).tooltip("在目标点附近的这个范围内随机生成").maxTextLength(6).padLeft(4f);
randDstTable.add("格").expandX().left();
}).row();
rightTable.add(itemTable).row();
rightTable.add(propertiesTable).row();

rightTable.defaults().padTop(12f);
rightTable.add(teamTable).row();

rightTable.add(posTable).row();
rightTable.add(countTable).row();
rightTable.table(randDstTable -> {
randDstTable.add("生成范围:");
randDstTable.field(Strings.autoFixed(unitRandDst, 3), text -> {
unitRandDst = Float.parseFloat(text);
}).valid(Strings::canParsePositiveFloat).tooltip("在目标点附近的这个范围内随机生成").maxTextLength(6).padLeft(4f);
randDstTable.add("格").expandX().left();
}).row();
rightTable.add(itemTable).row();
rightTable.add(propertiesTable).row();
rightTable.table(bottomTable -> {
bottomTable.left();
bottomTable.defaults().top().left();

rightTable.add(teamTable).row();
bottomTable.add(effectTable);

rightTable.table(bottomTable -> {
bottomTable.left();
bottomTable.defaults().top().left();
bottomTable.defaults().padLeft(16f);
bottomTable.add(payloadTable);
}).padTop(8f).fillY();

bottomTable.add(effectTable);
Cell<?> unitPropsTable, selectionCell = main.add(selection);

bottomTable.defaults().padLeft(16f);
bottomTable.add(payloadTable);
}).padTop(8f).fillY();
});
if(Core.graphics.isPortrait()){
main.row();
}

if(Core.graphics.isPortrait()){
unitPropsTable = main.add(rightTable);
}else{
unitPropsTable = main.pane(Styles.noBarPane, rightTable).scrollX(false);
}

if(Core.graphics.isPortrait()){
selectionCell.maxHeight(10 * 64f);
selectionCell.padBottom(8f);
}else{
selectionCell.padRight(8f);
selectionCell.expand(1, 1).fill();
mainCell.expand(4, 1).fill();
unitPropsTable.expand(4, 1).fill();
}
}

Expand Down Expand Up @@ -499,7 +505,7 @@ private void rebuildItemTable(Unit unit, Table itemTable){
changeItem[0].get(null);
}).size(48f).padLeft(4);

Slider slider = itemTable.slider(0, itemCapacity, 1, 1, n -> {
Slider slider = itemTable.slider(0, itemCapacity, 1, unit.stack.amount, n -> {
changeItemCount[0].get((int)n);
}).width(128f).padLeft(4).get();

Expand All @@ -513,6 +519,10 @@ private void rebuildItemTable(Unit unit, Table itemTable){
field.setText("" + n);
slider.setValue(n);
};

if(unit.stack.amount > itemCapacity){
changeItemCount[0].get(itemCapacity);
}
}

private void rebuildTeamTable(Unit unit, Table teamTable){
Expand Down Expand Up @@ -639,7 +649,7 @@ private void rebuildEffectsTable(Unit unit, Table effectTable){

effectTable.row();

effectTable.pane(noBarPane, settingTable).fillY();
effectTable.add(settingTable).fillY();
rebuildEffectSettingTable(unitStatus, settingTable);
}

Expand Down Expand Up @@ -803,7 +813,7 @@ private void simpleFactory(Unit unit){
Table main = new Table();

float width = Core.scene.getWidth() * (Core.scene.getWidth() > 1500 ? 0.6f : 0.9f) / Scl.scl(1);
dialog.cont.add(main).width(width).growY();
dialog.cont.pane(Styles.noBarPane, main).scrollX(false).width(width).growY();

main.top();
main.defaults().growX();
Expand Down

0 comments on commit 5fd2f11

Please sign in to comment.