Skip to content

Commit

Permalink
Weapon modules tab in core database
Browse files Browse the repository at this point in the history
  • Loading branch information
Slotterleet committed Nov 20, 2024
1 parent 400140f commit b6c3de7
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 107 deletions.
15 changes: 2 additions & 13 deletions res/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@ stat.fos-healthtrigger = activates at [accent]<{0}%[] health
stat.fos-aciddamage = [stat]{0}[] [lightgray]acid damage/sec[]
stat.fos-acidrange = [stat]{0}[] [lightgray]tiles acid range[]

unittype = [gray]Type: []
unittype.infantry = [accent]Infantry[]
unittype.flying = [accent]Flying[]
unittype.spider = [#665c9f]Spider[]
unittype.ship = [blue]Ship[]
unittype.payload = [#98ffa9]Payload[]
unittype.tank = [orange]Tank[]
unittype.timedkill = [purple]Timed[]
unittype.hover = [acid]Hover[]
unittype.tether = [sky]Tether[]
unittype.crawl = [crimson]Crawler[]
unittype.support = [#98ffa9](Support)[]

team.corru.name = Corru
team.bessin.name = Bessin

Expand Down Expand Up @@ -86,6 +73,8 @@ setting.fos-debugmode.name = [red]Danger Zone: []Debug Mode
setting.fos-debugmode.description = Enables debug-only features. Not recommended for players.\nRestart required to apply changes.
setting.fos-unlock-all-content = Unlock all content.

content.fos-weaponmodules.name = Weapon Modules

block.fos-resource-extractor.name = Resource Extractor
block.fos-resource-extractor.description = Refines inputted materials into their metal components. Output can be selected.
block.fos-cuberium-synthesizer.name = Cuberium Synthesizer
Expand Down
17 changes: 3 additions & 14 deletions res/bundles/bundle_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@ stat.fos-healthtrigger = включается при [accent]<{0}%[] прочн
stat.fos-aciddamage = [stat]{0}[] [lightgray]урона/сек кислотой[]
stat.fos-acidrange = [stat]{0}[] [lightgray]блоков радиус кислоты[]

unittype = [gray]Тип: []
unittype.infantry = [accent]Пехота[]
unittype.flying = [accent]Летающий[]
unittype.spider = [#665c9f]Паук[]
unittype.ship = [blue]Корабль[]
unittype.payload = [#98ffa9]Грузовой[]
unittype.tank = [orange]Танк[]
unittype.timedkill = [purple]Временный[]
unittype.hover = [acid]Парящий[]
unittype.tether = [sky]Tether[]
unittype.crawl = [crimson]Ползущий[]
unittype.support = [#98ffa9](Поддержка)[]

team.corru.name = Корру
team.bessin.name = Бессин

Expand All @@ -83,9 +70,11 @@ setting.fos-ostdontshowagain.name = Не показывать сообщение
setting.fos-ostdontshowagain.description = Отключить напоминание загрузить FOS OST при запуске игры.
setting.fos-refreshsplash.name = Обновить подзаголовок мода
setting.fos-debugmode.name = [red]Опасная зона: []Режим отладки
setting.fos-debugmode.description = Включает функции отладки. Не рекомендуется для игроков.\nПерезагрузите игру, чтобы изменения вступили в силу.\nПерезагрузите игру, чтобы изменения вступили в силу.
setting.fos-debugmode.description = Включает функции отладки. Не рекомендуется для игроков.\nПерезагрузите игру, чтобы изменения вступили в силу.
setting.fos-unlock-all-content = Разблокировать весь контент.

content.fos-weaponmodules.name = Модули оружия

block.fos-resource-extractor.name = Экстрактор ресурсов
block.fos-resource-extractor.description = Перебирает камни на ресурсы на случай, если надо больше.
block.fos-cuberium-synthesizer.name = Синтезатор кубрия
Expand Down
50 changes: 5 additions & 45 deletions src/fos/content/FOSWeaponModules.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
//just because it looks nicer :)
public class FOSWeaponModules {
public static WeaponSet
standard1, standard2, standard3, standard4, standard5,
shotgun1, shotgun2, shotgun3, shotgun4, shotgun5,
support1, support2, support3, support4, support5,
standard1, standard2, standard3, standard4,
shotgun1, shotgun2, shotgun3, shotgun4,
support1, support2, support3, support4,
legionFabricator, citadelStickyLauncher;

public static void load() {
Expand Down Expand Up @@ -100,47 +100,8 @@ public static void load() {
homingPower = 0.8f;
}};
}}).reqs(with(zinc, 250, silicon, 200, vanadium, 100));
//TODO: placeholders
//TODO: placeholder
standard4 = new WeaponSet("standard4", new Weapon("fos-standard-weapon4")).reqs(with(lead, 1));
standard5 = new WeaponSet("standard5", new Weapon("fos-standard-weapon5"){{
x = 0; y = 0;
alternate = mirror = false;
rotate = true;
top = true;
recoil = 4f;
reload = recoilTime = 10f;
bullet = new BasicBulletType(13f, 240){{
pierce = true;
pierceCap = 10;
width = 14f;
height = 33f;
lifetime = 15f;
shootEffect = Fx.shootBig;
trailLength = 24;
fragVelocityMin = 0.4f;

hitEffect = Fx.blastExplosion;
splashDamage = 18f;
splashDamageRadius = 13f;

fragBullets = 3;
fragLifeMin = 0f;
fragRandomSpread = 30f;

fragBullet = new BasicBulletType(9f, 20){{
width = 10f;
height = 10f;
pierce = true;
pierceBuilding = true;
pierceCap = 3;

lifetime = 20f;
hitEffect = Fx.flakExplosion;
splashDamage = 15f;
splashDamageRadius = 10f;
}};
}};
}}).reqs(with(zinc, 500, silver, 500, vanadium, 300, nickel, 250, luminium, 200));

// SHOTGUNS
shotgun1 = new WeaponSet("shotgun1"){{
Expand Down Expand Up @@ -221,9 +182,8 @@ public static void load() {
}};
}};
}}).reqs(with(zinc, 200, silver, 50, silicon, 200, vanadium, 100));
//TODO: placeholders
//TODO: placeholder
shotgun4 = new WeaponSet("shotgun4", new Weapon()).reqs(with(lead, 1));
shotgun5 = new WeaponSet("shotgun5", new Weapon()).reqs(with(lead, 1));

// SUPPORT MODULES
support1 = new WeaponSet("support1"){{
Expand Down
31 changes: 2 additions & 29 deletions src/fos/type/WeaponSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import mindustry.entities.units.WeaponMount;
import mindustry.gen.Unit;
import mindustry.type.*;
import mindustry.ui.Styles;
import mindustry.world.meta.*;

//YES, this looks very cursed lmao
Expand Down Expand Up @@ -39,6 +38,8 @@ public WeaponSet(String name) {
id = sets.size;
sets.add(this);
permanent = false;

show = false;
}

public WeaponSet(String name, Weapon... weapons) {
Expand Down Expand Up @@ -145,33 +146,5 @@ public WeaponSet produceTime(float ticks) {

return this;
}

// Stolen from Mindustry v146 because this mod's annotation processor is outdated as fuck.
// @nekit508 pls fix
public static StatValue abilities(Seq<Ability> abilities) {
return table -> {
table.row();
table.table(t -> {
int count = 0;
for(Ability ability : abilities){
if(ability.display){
t.table(Styles.grayPanel, a -> {
a.add("[accent]" + ability.localized()).padBottom(4).center().top().expandX();
a.row();
a.left().top().defaults().left();
if(Core.bundle.has(ability.localized() + ".description")){
a.add(Core.bundle.get(ability.localized() + ".description")).wrap().width(350f);
a.row();
}
}).pad(5).margin(10).growX().top().uniformX();
if((++count) == 2){
count = 0;
t.row();
}
}
}
});
};
}
}

85 changes: 79 additions & 6 deletions src/fos/ui/UIHandler.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package fos.ui;

import arc.Events;
import arc.*;
import arc.graphics.Color;
import arc.graphics.g2d.Draw;
import arc.input.KeyCode;
import arc.math.Mathf;
import arc.scene.*;
import arc.scene.ui.ImageButton;
import arc.scene.event.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.util.Reflect;
import arc.struct.Seq;
import arc.util.*;
import fos.core.FOSVars;
import fos.type.WeaponSet;
import fos.ui.menus.*;
import mindustry.Vars;
import mindustry.ctype.UnlockableContent;
import mindustry.game.*;
import mindustry.gen.Tex;
import mindustry.graphics.Layer;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.mod.Mods;
import mindustry.ui.Styles;
import mindustry.ui.*;
import mindustry.ui.dialogs.PlanetDialog;

import static arc.Core.*;
Expand Down Expand Up @@ -120,5 +128,70 @@ public void draw() {
}
});
}

// dedicated weapon module tab in core DB
ui.database.shown(() -> {
WidgetGroup w = (WidgetGroup) ui.database.getChildren().get(1);
w = (WidgetGroup) w.getChildren().get(1);
w = (WidgetGroup) w.getChildren().get(0);

Table t = (Table)w;

Seq<WeaponSet> array = WeaponSet.sets;

t.add("@content.fos-weaponmodules.name").growX().left().color(Pal.accent);
t.row();
t.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
t.row();
t.table(list -> {
list.left();

int cols = (int) Mathf.clamp((Core.graphics.getWidth() - Scl.scl(30)) / Scl.scl(32 + 12), 1, 22);
int count = 0;

for(int i = 0; i < array.size; i++){
UnlockableContent unlock = array.get(i);

Image image = unlocked(unlock) ? new Image(unlock.uiIcon).setScaling(Scaling.fit) : new Image(Icon.lock, Pal.gray);

//banned cross
if(state.isGame() && state.rules.tags.get("fos-bannedMountUpgrades") != null && state.rules.tags.get("fos-bannedMountUpgrades").contains(unlock.name)) {
list.stack(image, new Image(Icon.cancel){{
setColor(Color.scarlet);
touchable = Touchable.disabled;
}}).size(8 * 4).pad(3);
}else{
list.add(image).size(8 * 4).pad(3);
}

ClickListener listener = new ClickListener();
image.addListener(listener);
if(!mobile && unlocked(unlock)){
image.addListener(new HandCursorListener());
image.update(() -> image.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta)));
}

if(unlocked(unlock)){
image.clicked(() -> {
if(Core.input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(unlock.name) != 0){
Core.app.setClipboardText((char)Fonts.getUnicode(unlock.name) + "");
ui.showInfoFade("@copied");
}else{
ui.content.show(unlock);
}
});
image.addListener(new Tooltip(tt -> tt.background(Tex.button).add(unlock.localizedName + (settings.getBool("console") ? "\n[gray]" + unlock.name : ""))));
}

if((++count) % cols == 0){
list.row();
}
}
}).growX().left().padBottom(10);
});
}

static boolean unlocked(UnlockableContent content) {
return (!Vars.state.isCampaign() && !Vars.state.isMenu()) || content.unlocked();
}
}

0 comments on commit b6c3de7

Please sign in to comment.