2026-06-20 21:45:01 +02:00
|
|
|
package de.winniepat.parrotmod.ui;
|
|
|
|
|
|
2026-06-20 22:10:10 +02:00
|
|
|
import de.winniepat.parrotmod.Parrotmod;
|
2026-06-20 22:58:27 +02:00
|
|
|
import de.winniepat.parrotmod.config.ConfigManager;
|
2026-06-20 21:45:01 +02:00
|
|
|
import icyllis.modernui.fragment.Fragment;
|
|
|
|
|
import icyllis.modernui.util.DataSet;
|
|
|
|
|
import icyllis.modernui.view.*;
|
|
|
|
|
import icyllis.modernui.widget.*;
|
2026-06-20 22:10:10 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
2026-06-20 21:45:01 +02:00
|
|
|
|
|
|
|
|
public class GeneralTabFragment extends Fragment {
|
|
|
|
|
|
|
|
|
|
@Override
|
2026-06-20 22:10:10 +02:00
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, DataSet savedInstanceData) {
|
2026-06-20 21:45:01 +02:00
|
|
|
LinearLayout layout = new LinearLayout(getContext());
|
|
|
|
|
layout.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
layout.setPadding(dp(12), dp(12), dp(12), dp(12));
|
|
|
|
|
|
2026-06-20 22:10:10 +02:00
|
|
|
layout.addView(makeLabel("Minecraft Version: " + Minecraft.getInstance().getLaunchedVersion()));
|
2026-06-20 21:45:01 +02:00
|
|
|
|
2026-06-20 22:58:27 +02:00
|
|
|
Button reloadBtn = new Button(getContext());
|
|
|
|
|
reloadBtn.setText("Reload Config");
|
|
|
|
|
reloadBtn.setOnClickListener(v -> ConfigManager.load());
|
|
|
|
|
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
p.topMargin = dp(16);
|
|
|
|
|
layout.addView(reloadBtn, p);
|
|
|
|
|
|
|
|
|
|
Button saveBtn = new Button(getContext());
|
|
|
|
|
saveBtn.setText("Save Config");
|
|
|
|
|
saveBtn.setOnClickListener(v -> ConfigManager.save());
|
|
|
|
|
layout.addView(saveBtn, p);
|
|
|
|
|
|
2026-06-20 21:45:01 +02:00
|
|
|
return layout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TextView makeLabel(String text) {
|
|
|
|
|
TextView tv = new TextView(getContext());
|
|
|
|
|
tv.setText(text);
|
|
|
|
|
tv.setTextSize(12);
|
|
|
|
|
tv.setTextColor(0xFFCCCCCC);
|
2026-06-20 22:10:10 +02:00
|
|
|
var p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
2026-06-20 21:45:01 +02:00
|
|
|
p.topMargin = dp(8);
|
|
|
|
|
p.bottomMargin = dp(2);
|
|
|
|
|
tv.setLayoutParams(p);
|
|
|
|
|
return tv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int dp(float dp) {
|
|
|
|
|
return (int) (dp * getContext().getResources().getDisplayMetrics().density);
|
|
|
|
|
}
|
|
|
|
|
}
|