Skip to content

Commit

Permalink
Merge branch 'master' into yzh
Browse files Browse the repository at this point in the history
  • Loading branch information
YaeSakuraQvQ committed Aug 10, 2023
2 parents ba30711 + 07996a3 commit ef66aca
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 238 deletions.
7 changes: 4 additions & 3 deletions assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ mindow2.settings.allIntro = This dialog lists all settings of MI2U, including se
mindow2.settings.curMindowName = Current Mindow2 Name is: \n
mindow2.settings.noMindowNameWarning = Mindow2 Has No Name, \nUI settings Not Available.
mindow2.settings.help = Help Info
settings.mindow2.scale = Scaling UI 5% ~ 400%
settings.main.playerCursor = Player Cursor
settings.main.overdriveZone = Overdrive Zone
settings.main.menderZone = Mender Zone
Expand Down Expand Up @@ -150,8 +151,7 @@ settings.mindowMap.drawFog = Fog
settings.mindowMap.drawIndicator = Attack Indicator
settings.mindowMap.drawObjective = Map Objective
settings.mindowMap.size = Minimap Size(Def=140)
settings.mindowMap.worldDataUpdate = Auto-Update World Data for Space-Scan world finder, otherwise update on each find action
settings.mindowMap.worldDataUpdate.interval = Auto Update Interval (Second)
settings.mindowMap.worldDataUpdate.tiles = Space-Scan World Tiles Update Per Tick

mindow2.helpInfoTitle = Help
mindow2.uiHelp = Mindow2 is a lite window developed by MI2U.\
Expand Down Expand Up @@ -203,4 +203,5 @@ fullAI.help = Logic Custom AI can control player unit with processor code. After
\n\n[accent]@unit[] Permanently automatically bind player units, cannot be changed. So [accent]Ucontrol, Ulocate, etc.[], can be used directly.\
\n\nPlayer actions are divided into two parts: move, attack, and two timers are independent. 10s without control or using [accent]idle|stop[] will release the control to other AIs.\
\n\nLogic is based on world processor and can use world-sense instructions, but world-modifying and unsimulable instructions only work in single-player sandbox, such as [accent]SetProp, Write, SetBlock, etc.[] \
\n\nAlternative implementations by simulating player for some instructions, such as [accent]Control-config[].
\n\nAlternative implementations by simulating player for some instructions, such as [accent]Control-config[].\
\n\nThe Developer shall not be liable for any consequences arising from the improper use of this feature.
7 changes: 4 additions & 3 deletions assets/bundles/bundle_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ mindow2.settings.allIntro = 本界面罗列了MI2U的所有选项,包括各窗
mindow2.settings.curMindowName = 当前调整的Mindow2的名称是:\n
mindow2.settings.noMindowNameWarning = Mindow2没有名称,UI选项不可用。
mindow2.settings.help = 帮助信息
settings.mindow2.scale = 缩放UI 5% ~ 400%
settings.main.playerCursor = 玩家光标
settings.main.overdriveZone = 超速区域显示
settings.main.menderZone = 修理器区域显示
Expand Down Expand Up @@ -150,8 +151,7 @@ settings.mindowMap.drawFog = 显示迷雾
settings.mindowMap.drawIndicator = 显示攻击警告
settings.mindowMap.drawObjective = 显示地图目标
settings.mindowMap.size = 小地图尺寸(原版=140)
settings.mindowMap.worldDataUpdate = 为天眼查找器自动更新世界数据,否则在每次查找时可能检查更新
settings.mindowMap.worldDataUpdate.interval = 数据自动更新时间间隔(秒)
settings.mindowMap.worldDataUpdate.tiles = 天眼查世界数据每帧更新格数

mindow2.helpInfoTitle = 帮助信息
mindow2.uiHelp = Mindow2是MI2U开发的简易窗体。\
Expand Down Expand Up @@ -203,4 +203,5 @@ fullAI.help = 逻辑自定义AI可以用逻辑代码控制玩家单位行动.
\n\n[accent]@unit[]永久自动绑定玩家单位, 不能换绑, 解绑. 所以[accent]Ucontrol, Ulocate[]等可以直接使用。\
\n\n玩家动作分为两部分: 移动, 攻击, 2个计时器相互独立. 10s不进行控制或者使用[accent]idle, stop[], 就会释放控制权给其他AI.\
\n\n逻辑基于世界处理器, 可以使用世处的感知世界的指令, 但不能模拟的, 修改世界的指令只能在单人沙盒生效, 例如[accent]SetProp, Write, SetBlock[]等. \
\n\n部分逻辑功能通过模拟玩家实现, 例如[accent]Control-config[].
\n\n部分逻辑功能通过模拟玩家实现, 例如[accent]Control-config[].\
\n\n开发者对不当使用本功能产生的后果无需承担任何责任. Never Mind the Scandal and Liber.
2 changes: 1 addition & 1 deletion assets/shaders/menderzone.frag
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main(){
if(color.a <= 0.001 && maxed.a > 0.01){
gl_FragColor = vec4(u_color.rgb, 0.3);
}else if(color.a > 0.001){
gl_FragColor = vec4(u_color.rgb, color.b > 0.05 ? 0.1 + color.b * 0.5 : 0.1);
gl_FragColor = vec4(u_color.rgb, 0.1 + color.b * 0.4);
}else{
gl_FragColor = color;
}
Expand Down
Binary file added assets/sprites/ui-aicfg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/ui-centermove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/ui-shoot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/ui-speed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories{

ext{
//the build number that this mod is made for
mindustryVersion = 'v145'
mindustryVersion = 'v145.1'
jabelVersion = "0.7.0"
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
}
Expand Down
2 changes: 1 addition & 1 deletion mod.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ displayName: "MI2-Utilities Java"
name: "MI2-Utilities-Java"

#the mod version
version: 1.3.5
version: 1.4.2

#the minimum game build required to run this mod
minGameVersion: 145
Expand Down
7 changes: 7 additions & 0 deletions src/mi2u/MI2UVars.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package mi2u;

import arc.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.scene.ui.TextButton.*;
import arc.struct.*;
Expand All @@ -18,6 +23,8 @@ public class MI2UVars{
c.margin(6f);
};

public static Drawable fadeBackground;

public static Seq<Mindow2> mindow2s = new Seq<>();

public static FullAI fullAI = new FullAI();
Expand Down
17 changes: 17 additions & 0 deletions src/mi2u/MI2Utilities.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package mi2u;

import arc.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.util.*;
import mi2u.graphics.*;
Expand Down Expand Up @@ -29,13 +33,26 @@ public MI2Utilities(){
MOD = mods.getMod(MI2Utilities.class);
titleButtonSize = 32f;

Pixmap fade = new Pixmap(128, 128);
for(int x = 0; x < fade.width; x++){
for(int y = 0; y < fade.height; y++){
FloatFloatf func = f -> Mathf.pow(f, 0.6f);
fade.set(x, y, MI2UTmp.c2.set(Color.black).a(0.4f * func.get(
Math.min(x, Math.min(y, Math.min(fade.width-x-1, fade.height-y-1))) / (fade.width/2f)
)));
}
}
Core.atlas.addRegion("fadeBackground", new TextureRegion(new Texture(fade)));
fadeBackground = new TextureRegionDrawable(Core.atlas.find("fadeBackground"));

Mindow2.initMindowStyles();
MI2USettings.init();
InputUtils.init();

maxSchematicSize = MI2USettings.getInt("maxSchematicSize", 64);
renderer.maxZoom = Strings.parseFloat(MI2USettings.getStr("maxZoom", "6"));
renderer.minZoom = Strings.parseFloat(MI2USettings.getStr("minZoom", "1.5"));

Time.runTask(40f, () -> {
mi2ui.addTo(Core.scene.root);
mi2ui.visible(() -> state.isGame() && ui.hudfrag.shown);
Expand Down
38 changes: 24 additions & 14 deletions src/mi2u/ai/FullAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import arc.graphics.*;
import arc.math.*;
import arc.math.geom.*;
import arc.scene.style.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
Expand Down Expand Up @@ -45,8 +46,10 @@ public FullAI(){
modes.add(new LogicMode());

Events.run(EventType.Trigger.update, () -> {
fullAI.unit(player.unit());
fullAI.updateUnit();
if(state.isGame() && state.isPlaying()){
fullAI.unit(player.unit());
fullAI.updateUnit();
}
});
}

Expand All @@ -61,7 +64,9 @@ public void updateUnit(){
}
if(control.input instanceof InputOverwrite inp){
inp.clear();
modes.each(Mode::act);
modes.each(mode -> {
if(mode.enable) mode.act();
});
}
}

Expand All @@ -85,10 +90,11 @@ public void shootAction(Vec2 point, Boolean shoot){
public class Mode{
public boolean enable = false;
public String btext;
public Drawable bimg;
public Mode(){
btext = Iconc.units + "";
}
/** override it. enable should be checked first */
/** override it. enable auto checked. */
public void act(){}

public void buildConfig(Table table){
Expand All @@ -99,7 +105,11 @@ public void buildConfig(Table table){
}, textb, () -> {
enable = !enable;
}).size(16f);
t.add(btext).color(Color.sky).left();
if(bimg != null){
t.image(bimg).size(18f).scaling(Scaling.fit);
}else{
t.add(btext).color(Color.sky).left();
}
t.add().growX();
}).growX().minHeight(18f).padTop(8f);
table.row();
Expand All @@ -119,7 +129,6 @@ public BaseMineMode(){

@Override
public void act(){
if(!enable) return;
Building core = unit.closestCore();
boostAction(true);
if(!(unit.canMine()) || !unit.type.mineFloor || core == null) return;
Expand Down Expand Up @@ -211,7 +220,6 @@ public AutoBuildMode(){
}
@Override
public void act(){
if(!enable) return;
if(!control.input.isBuilding) return;
if(!unit.canBuild()) return;
//help others building, catching the closest plan to co-op.
Expand Down Expand Up @@ -321,7 +329,6 @@ public SelfRepairMode(){
}
@Override
public void act(){
if(!enable) return;
if(unit.dead || !unit.isValid()) return;
if(unit.health > unit.maxHealth * hold) return;
Building tile = Geometry.findClosest(unit.x, unit.y, indexer.getFlagged(unit.team, BlockFlag.repair));
Expand All @@ -341,10 +348,10 @@ public class AutoTargetMode extends Mode{
public boolean attack = true, heal = true;
public AutoTargetMode(){
btext = "AT";
bimg = Core.atlas.drawable("mi2-utilities-java-ui-shoot");
}
@Override
public void act(){
if(!enable) return;
if(Core.input.keyDown(Binding.select)) return;

if(timer.get(6, 30f)){
Expand Down Expand Up @@ -384,6 +391,7 @@ public class CenterFollowMode extends Mode{
public CenterFollowMode(){
btext = Iconc.move + "";
enable = mobile;
bimg = Core.atlas.drawable("mi2-utilities-java-ui-centermove");
}
@Override
public void act(){
Expand Down Expand Up @@ -457,6 +465,7 @@ public class LogicMode extends Mode{
MI2Utils.IntervalMillis actionTimer = new MI2Utils.IntervalMillis(2);
public boolean itemTrans, payloadTrans;
public static StringBuffer log = new StringBuffer();
Queue<BuildPlan> plans = new Queue<>();

//public int lastPathId = 0;
//public float lastMoveX, lastMoveY;
Expand All @@ -474,8 +483,6 @@ public LogicMode(){

@Override
public void act(){
if(!enable) return;
ai.unit(unit);
var ctrl = unit.controller();
unit.controller(ai);

Expand All @@ -486,6 +493,8 @@ public void act(){
ai.updateMovement();
}

plans.clear();
if(unit.plans != null) unit.plans.each(bp -> plans.add(bp));
for(int i = 0; i < Mathf.clamp(instructionsPerTick, 1, 2000); i++){
if(exec.instructions.length == 0) break;
exec.setconst(LExecutor.varUnit, unit);
Expand All @@ -499,6 +508,7 @@ public void act(){
}
exec.runOnce();
}
if(unit.plans != null && unit.plans.isEmpty()) plans.each(bp -> unit.plans.add(bp));

unit.controller(ctrl);
fullAI.unit(unit);
Expand Down Expand Up @@ -535,7 +545,7 @@ public void buildConfig(Table table){
ui.logic.show(code, exec, true, str -> {
readCode(str);
});
}).grow();
}).grow().minWidth(40f);
t.add("ipt=");
t.field(String.valueOf(instructionsPerTick), TextField.TextFieldFilter.digitsOnly, str -> instructionsPerTick = Strings.parseInt(str)).growX();
t.button(Iconc.info + "", textb, () -> {
Expand All @@ -545,11 +555,11 @@ public void buildConfig(Table table){
table.row();
table.add("Print Log").left().color(Color.royal);
table.row();
table.table(t -> {
table.pane(t -> {
t.name = "log";
t.image().color(Color.royal).growY().width(2f);
t.labelWrap(() -> log).grow();
}).grow();
}).grow().maxHeight(200f);

}

Expand Down
8 changes: 4 additions & 4 deletions src/mi2u/graphics/RendererExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -609,15 +609,15 @@ public static void drawMender(MendProjector.MendBuild mb){
if(animatedshields){
Draw.color(pulse > 0.9f ? Color.blue : Color.green);
Draw.alpha(0.1f);
Fill.poly(mb.x, mb.y, 24, block.range + mb.phaseHeat * block.phaseRangeBoost);
Fill.poly(mb.x, mb.y, 18, block.range + mb.phaseHeat * block.phaseRangeBoost);
Draw.color(Color.blue, pulse > 0.1f ? pulse * 0.5f : 0f);
Lines.poly(mb.x, mb.y, 24, block.range + mb.phaseHeat * block.phaseRangeBoost);
Lines.poly(mb.x, mb.y, 18, block.range + mb.phaseHeat * block.phaseRangeBoost);
}else{
Draw.color(block.baseColor);
Draw.alpha(0.05f * pulse);
Fill.poly(mb.x, mb.y, 24, block.range + mb.phaseHeat * block.phaseRangeBoost);
Fill.poly(mb.x, mb.y, 18, block.range + mb.phaseHeat * block.phaseRangeBoost);
Draw.color(block.baseColor, pulse > 0.1f ? pulse * 0.5f : 0f);
Lines.poly(mb.x, mb.y, 24, block.range + mb.phaseHeat * block.phaseRangeBoost);
Lines.poly(mb.x, mb.y, 18, block.range + mb.phaseHeat * block.phaseRangeBoost);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/mi2u/io/MI2USettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public static void save(){

}

//TODO better validation and default.
public static class MI2USetting{
public String name;
protected String value;
Expand Down Expand Up @@ -295,6 +296,7 @@ public FieldEntry(String name, String help, String def, TextFieldFilter filter,
this.filter = filter;
this.validator = validator;
if(setting == null) setting = putStr(name, def); //父类构造时已按name尝试抓取,子类构造只需要按def类型处理put
if(this.validator != null && !validator.valid(setting.value)) setting.value = def;
}

@Override
Expand Down
Loading

0 comments on commit ef66aca

Please sign in to comment.