use of main.swing.generic.components.G_Panel in project Eidolons by IDemiurge.
the class MusicListPanel method initCustomViews.
protected void initCustomViews() {
List<File> topList = new ArrayList<>();
Map<String, List<String>> customMap = new XLinkedMap<>();
for (File file : FileManager.getFilesFromDirectory(AHK_Master.CUSTOM_LISTS_FOLDER, true)) {
if (file.isDirectory()) {
String name = file.getName();
G_Panel view = initView(getCustomMap(name, FileManager.getFilesFromDirectory(file.getPath(), false), customMap), isLetterShown());
// viewsPanel.addView(file.getName(), view);
} else {
topList.add(file);
}
}
// add root to the subpanel map
Map<String, List<String>> map = getCustomMap(topList, customMap);
MusicListPanel panel = new MusicListPanel(key, map);
panel.setView(panel.initView(map, isLetterShown()));
viewsPanel.addView("Custom", panel);
}
use of main.swing.generic.components.G_Panel in project Eidolons by IDemiurge.
the class MusicListPanel method initView.
public G_Panel initView(final Map<String, List<String>> map, Boolean letterShown, final int customWrap, final List<String> musicConsts) {
lastMap = map;
final G_Panel view = new ListButtonPanel(map, this, customWrap, musicConsts);
view.refresh();
return view;
}
use of main.swing.generic.components.G_Panel in project Eidolons by IDemiurge.
the class MusicCore method getFilterView.
public static MusicListPanel getFilterView(String filterVal, PROPERTY filterProp) {
Map<String, List<String>> map = new XLinkedMap<>();
String name = filterProp.getName() + " by " + filterVal;
MusicListPanel panel = new MusicListPanel(name, map);
int maxSize = 0;
int i = 0;
for (String substring : StringMaster.open(filterVal)) {
List<String> list = new ArrayList<>();
for (ObjType type : DataManager.getTypes(AT_OBJ_TYPE.MUSIC_LIST)) {
if (type.checkProperty(filterProp, substring)) {
list.add(type.getProperty(G_PROPS.HOTKEY) + "::" + type.getProperty(AT_PROPS.PATH));
}
}
if (maxSize < list.size()) {
maxSize = list.size();
}
map.put(i + "", list);
i++;
}
List<String> musicConsts = StringMaster.openContainer(filterVal);
int customWrap = 2 + maxSize / 14;
if (customWrap < 0) {
customWrap = 0;
}
G_Panel v = panel.initView(map, false, customWrap, musicConsts);
panel.setView(v);
panel.setName(name);
v.setName(name);
return panel;
}
use of main.swing.generic.components.G_Panel in project Eidolons by IDemiurge.
the class UnitGroupMaster method chooseUnit.
private static ObjType chooseUnit(ObjType factionType, int power, int max_power) {
Map<ObjType, Integer> pool = initPool(factionType);
List<ObjType> available = new ArrayList<>();
for (ObjType l : pool.keySet()) {
if (getUnitCost(l, factionType) > power) {
continue;
}
if (l.getIntParam(PARAMS.POWER) > max_power) {
continue;
}
available.add(l);
}
if (available.isEmpty()) {
return null;
}
// chooseUnit();
Map<String, String> map = new HashMap<>();
for (ObjType type : pool.keySet()) {
map.put(type.getName(), "Cost: " + pool.get(type) + "; Power: " + type.getIntParam(PARAMS.POWER));
}
ListChooser.setDecorator(new Decorator() {
@Override
public void addComponents(G_Panel panel) {
G_ListPanel<ObjType> list = // new CustomList<>(getUnitList());
new G_ListPanel<ObjType>(getUnitList()) {
@Override
public void setInts() {
wrap = 1;
minItems = max;
rowsVisible = 1;
layoutOrientation = JList.HORIZONTAL_WRAP;
}
@Override
public boolean isVertical() {
return false;
}
};
list.setPanelSize(new Dimension(300, 120));
panel.add(list, "pos tp.x decor_info.y2");
WrappedTextComp textComp = new WrappedTextComp(null) {
@Override
protected Color getColor() {
return Color.black;
}
@Override
public synchronized List<String> getTextLines() {
List<String> list = new ArrayList<>();
list.add(UnitGroupMaster.getRemainingPower() + " points remaining");
list.add("Size contraints: between " + min + " and " + max);
return list;
}
};
textComp.setDefaultSize(new Dimension(300, 120));
panel.add(textComp, "id decor_info, pos tp.x tp.y2");
}
});
ListChooser.setTooltipMapForComponent(map);
ListChooser.setSortingDisabled(true);
return ListChooser.chooseType_(available, DC_TYPE.UNITS);
// gui - a list per ally
}
use of main.swing.generic.components.G_Panel in project Eidolons by IDemiurge.
the class Launcher method initTopGUI.
private static void initTopGUI() {
frame = new G_Frame(MAIN_TITLE, true);
// setCustomCursor()
setCustomIcon();
if (!GuiManager.isWide()) {
frame.setLayout(new GridLayout());
viewPanel = new G_Panel();
viewPanel.setLayout(new GridLayout());
viewPanel.setSize(// TODO
GuiManager.getScreenSize());
frame.add(viewPanel, "pos 0 0");
} else {
DEV_MODE = false;
initBackground();
frame.add(background, "pos 0 0");
viewPanel = new G_Panel();
// otherwise there is this
viewPanel.setLayout(new GridLayout());
// size calc issue? viewPanel.setSize(VIEW_PANEL_SIZE);
double X = (GuiManager.getScreenWidth() - VIEW_PANEL_SIZE.getWidth()) / 2;
double Y = (GuiManager.getScreenHeight() - VIEW_PANEL_SIZE.getHeight()) / 2;
frame.setLayout(new MigLayout());
G_Panel panel = new G_Panel();
panel.setPanelSize(GuiManager.getScreenSize());
panel.setSize(GuiManager.getScreenSize());
panel.add(viewPanel, "pos " + X + " " + Y);
panel.setOpaque(true);
panel.setBackground(ColorManager.BACKGROUND);
frame.add(panel, "pos 0 0");
frame.setComponentZOrder(panel, 0);
frame.setComponentZOrder(background, 1);
}
if (fullscreen) {
GuiManager.setFullscreen(true);
GuiManager.setWindowToFullscreen(frame);
} else {
frame.setSize(GuiManager.getScreenSize());
// frame.setBackground(Color.black);
}
frame.setUndecorated(true);
frame.setVisible(true);
}
Aggregations