Skip to content

Commit

Permalink
Release of version v3.1
Browse files Browse the repository at this point in the history
 - Improvements to color changes while the tool is running.
 - Finalized the new file system.
  • Loading branch information
Xoriun committed Apr 23, 2022
1 parent 1bf8c41 commit 9ca046c
Show file tree
Hide file tree
Showing 17 changed files with 860 additions and 906 deletions.
8 changes: 4 additions & 4 deletions settings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<settings>
<last-notes-file>H:\Gaming\Factorio\any%_Nefrums - Kopie.txt</last-notes-file>
<last-notes-file>H:\Gaming\Factorio\any%_Nefrums_import.xml</last-notes-file>
<color-settings current="Dark">
<color-profile>
<name>Light</name>
Expand All @@ -16,9 +16,9 @@
</color-profile>
<color-profile>
<name>Custom</name>
<text>-1</text>
<border>-1</border>
<background>-1</background>
<text>-16776961</text>
<border>-16711936</border>
<background>-65536</background>
</color-profile>
</color-settings>
<hotkey-settings ctrl-workaround="true" current="">
Expand Down
859 changes: 476 additions & 383 deletions src/edit/CellEditDialog.java

Large diffs are not rendered by default.

47 changes: 30 additions & 17 deletions src/edit/SectionManagerDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@
import logic.AddRemoveControl;
import logic.MouseAdapters;

public class SectionManagerDialog
public class SectionManagerDialog extends JDialog
{
public static JDialog sectionManagerDialog;
public static JPanel sectionManagerPanel;
/** Automatically generated secrialVerionUID */
private static final long serialVersionUID = 4418008182269964040L;
private static JPanel sectionManagerPanel;

public static void initializeSectionDialog()
public SectionManagerDialog()
{
sectionManagerDialog = new JDialog(MainGui.window);
sectionManagerDialog.setTitle("Section Manager");
sectionManagerDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
sectionManagerDialog.setVisible(false);
super(MainGui.window);
this.setTitle("Section Manager");
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
this.setVisible(false);
}

public static void updateSectionManagerDialog()
public void updateSectionManagerDialog()
{
sectionManagerDialog.getContentPane().removeAll();
this.getContentPane().removeAll();

sectionManagerPanel = new JPanel();
sectionManagerPanel.setBackground(ColorSettings.getBackgroundColor());
Expand All @@ -53,7 +54,6 @@ public static void updateSectionManagerDialog()
label.addMouseListener(MouseAdapters.getEditSectionTitleAdapter(label, section_index) );
label.setBorder(GuiHelper.getDefaultBorder(section_index == 0, true) );
inner_panel.add(label, gbc);
MainGui.sectionLabels.add(label);

section_index ++;
gbc.gridy ++;
Expand All @@ -63,12 +63,25 @@ public static void updateSectionManagerDialog()
inner_panel.add(AddRemoveControl.createAddSectionControl(section_index), gbc);

sectionManagerPanel.add(inner_panel);
sectionManagerDialog.add(sectionManagerPanel);
this.add(sectionManagerPanel);

sectionManagerDialog.pack();
if (sectionManagerDialog.getHeight() > MainGui.screensize.height - 150)
sectionManagerDialog.setPreferredSize(new Dimension(sectionManagerDialog.getWidth() + 20, MainGui.screensize.height - 150) );
sectionManagerDialog.pack();
sectionManagerDialog.setVisible(true);
this.pack();
if (this.getHeight() > MainGui.screensize.height - 150)
this.setPreferredSize(new Dimension(this.getWidth() + 20, MainGui.screensize.height - 150) );
this.pack();
this.setVisible(true);
}

public void updateLightingMode()
{
//TODO
updateSectionManagerDialog();
}

public void updateEditMode()
{
this.updateSectionManagerDialog();
this.setVisible(MainGui.inEditMode);
this.pack();
}
}
23 changes: 19 additions & 4 deletions src/gui/Abbreviations.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import gui.MainGui;
import logic.FileOperations;
Expand Down Expand Up @@ -164,7 +165,7 @@ public void mouseClicked(MouseEvent e)
abbreviations_dialog.dispose();
textfield_list.remove(row);
abbr_list_copy.remove(abbr);
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfiles(textfield_list) );
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfields(textfield_list) );
}
} );
gbc.gridx = 3;
Expand Down Expand Up @@ -201,7 +202,7 @@ public void mouseClicked(MouseEvent e)
abbreviations_dialog.dispose();
textfield_list.remove(new_row);
abbr_list_copy.remove(new_abbr);
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfiles(textfield_list) );
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfields(textfield_list) );
}
} );
gbc.gridx = 3;
Expand Down Expand Up @@ -233,7 +234,7 @@ public void mouseClicked(MouseEvent e)
abbreviations_dialog.dispose();
FileOperations.unsavedChanges = true;
PopupAlerts.createMissingImagesMessage = true;
setAbbreviationsList(getAbbreviationsListFromTextfiles(textfield_list) );
setAbbreviationsList(getAbbreviationsListFromTextfields(textfield_list) );
FileOperations.imagesDirectory = images_dir;
FileOperations.fileAbbreviations = abbr_location;
FileOperations.saveAbbereviationsFile();
Expand All @@ -260,7 +261,12 @@ public static void setAbbreviationsList(ArrayList<String[]> abbreviations_list)
abbreviationsList = abbreviations_list.stream().sorted( (a,b) -> {return a[0].compareTo(b[0] ); } ).collect(Collectors.toCollection(ArrayList::new) );
}

private static ArrayList<String[]> getAbbreviationsListFromTextfiles(ArrayList<JTextField[]> textfields)
private static void sortAbbreviationList()
{
abbreviationsList = abbreviationsList.stream().sorted( (a,b) -> {return a[0].compareTo(b[0] ); } ).collect(Collectors.toCollection(ArrayList::new) );
}

private static ArrayList<String[]> getAbbreviationsListFromTextfields(ArrayList<JTextField[]> textfields)
{
return textfields.stream().map(row -> new String[] {row[0].getText(), row[1].getText() } ).collect(Collectors.toCollection(ArrayList::new) );
}
Expand Down Expand Up @@ -315,6 +321,15 @@ public static Element getAbbreviationsElement(Document doc)

public static void parseAbbreviationselement(Element abbreviaitons_element)
{
abbreviationsList.clear();

NodeList abbreviation_nodes = abbreviaitons_element.getElementsByTagName("abbreviation");
for (int i = 0; i < abbreviation_nodes.getLength(); i ++)
{
Element abbr = (Element) abbreviation_nodes.item(i);
abbreviationsList.add(new String[] {abbr.getElementsByTagName("abbr-short").item(0).getTextContent(), abbr.getElementsByTagName("abbr-long").item(0).getTextContent()} );
}

sortAbbreviationList();
}
}
2 changes: 1 addition & 1 deletion src/gui/ColorSettingProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ColorSettingProfile(Element profile, String current_profile_name)
ColorSettings.currentColorSetting = this;
}

public void update(Color text, Color border, Color background)
void update(Color text, Color border, Color background)
{
this.text = text;
this.border = border;
Expand Down
69 changes: 2 additions & 67 deletions src/gui/ColorSettings.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.JButton;
Expand All @@ -16,12 +12,6 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.MatteBorder;
import javax.swing.border.TitledBorder;

import edit.CellEditDialog;
import logic.Row;
import logic.Section;

public class ColorSettings
{
Expand All @@ -36,7 +26,7 @@ public class ColorSettings
static void selectColorSettings(int index)
{
currentColorSetting = colorSettingProfiles[index];
applyLightingMode();
MainGui.updateLightingSettings();
}

private static void fillColorSettingsPane(JPanel options_panel, ColorSettingProfile color_setting)
Expand Down Expand Up @@ -103,7 +93,7 @@ private static void fillColorSettingsRow(JPanel panel, GridBagConstraints gbc, C
private static void updateCustomColorSettings(JDialog options)
{
int[][] colors = new int[3][3];
getAllComponents(options).stream().filter(comp -> comp instanceof JTextField).forEach(text -> {
GuiHelper.getAllComponents(options).stream().filter(comp -> comp instanceof JTextField).forEach(text -> {
String name = text.getName();
colors[name.startsWith("Text") ? 0 : name.startsWith("Border") ? 1 : 2][name.endsWith("r") ? 0 : name.endsWith("g") ? 1 : 2] = getColorInt( (JTextField) text);
});
Expand All @@ -129,49 +119,6 @@ private static int getColorInt(JTextField text)

return res;
}

static void applyLightingMode()
{
// backgrounds
MainGui.window.setBackground(ColorSettings.getBackgroundColor() );
MainGui.scrollPane.setBackground(ColorSettings.getBackgroundColor() );
MainGui.mainPanel.setBackground(ColorSettings.getBackgroundColor() );

// text for cells
for (JLabel label : MainGui.labelsText) label.setForeground(ColorSettings.getTextColor() );

// text for add-remove-controls
for (JLabel label : MainGui.labelsTextsHideWhenNotInEdit) label.setForeground(MainGui.inEditMode ? ColorSettings.getTextColor() : ColorSettings.getBackgroundColor() );

// border color for sections
for (Section section : MainGui.sectionsList)
if (section.getBorder() != null)
((TitledBorder) section.getBorder() ).setTitleColor(ColorSettings.getTextColor() );

// border for cells
for (Section section : MainGui.sectionsList)
for (Row row : section.getRows() )
for (JPanel cell : row.getCells() )
if (cell.getBorder() != null)
cell.setBorder(new MatteBorder( ((MatteBorder) cell.getBorder() ).getBorderInsets(), ColorSettings.getBorderColor() ) );

// border for section label cells
for (JLabel label : MainGui.sectionLabels)
{
label.setBorder(new MatteBorder( ((MatteBorder) label.getBorder() ).getBorderInsets(), ColorSettings.getBorderColor() ) );
label.setForeground(ColorSettings.getTextColor() );
}

// background and border for sectionManagerDialog
if (edit.SectionManagerDialog.sectionManagerPanel!= null)
{
edit.SectionManagerDialog.sectionManagerPanel.setBackground(ColorSettings.getBackgroundColor() );
edit.SectionManagerDialog.sectionManagerPanel.setBorder(new MatteBorder( ((MatteBorder) edit.SectionManagerDialog.sectionManagerPanel.getBorder() ).getBorderInsets(), ColorSettings.getTextColor() ) );
}

// unpdate CellEditDialog
CellEditDialog.updateColorSettings();
}

static void changeCustomLightingSettings()
{
Expand Down Expand Up @@ -221,16 +168,4 @@ static void changeCustomLightingSettings()
options.setVisible(true);
options.repaint();
}

private static List<Component> getAllComponents(final Container c)
{
List<Component> compList = new ArrayList<Component>();
for (Component comp : c.getComponents()) {
compList.add(comp);
if (comp instanceof Container)
compList.addAll(getAllComponents((Container) comp));
}
return compList;
}

}
23 changes: 21 additions & 2 deletions src/gui/GuiHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
Expand Down Expand Up @@ -46,7 +48,13 @@ public class GuiHelper
*/
public static TitledBorder getTitledBorderWithCorrectTextColor(String title)
{
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED), title);
TitledBorder border = BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(
EtchedBorder.RAISED//,
//ColorSettings.getTextColor(),
//ColorSettings.getBorderColor()
),
title);
border.setTitleFont(MainGui.titleFont);
border.setTitleColor(ColorSettings.getTextColor());
return border;
Expand All @@ -60,7 +68,7 @@ public static TitledBorder getTitledBorderWithCorrectTextColor(String title)
*/
public static MatteBorder getSpacingBorder(int width)
{
return BorderFactory.createMatteBorder(width, width, width, width, ColorSettings.getBackgroundColor());
return BorderFactory.createMatteBorder(width, width, width, width, ColorSettings.getBackgroundColor() );
}

/**
Expand Down Expand Up @@ -402,4 +410,15 @@ private static ImageIcon getScaledLinebreakImageIcon()
throw new RuntimeException("Error while loading 'Linebreak.png', file doesn't exist!");
}
}

public static List<Component> getAllComponents(final Container c)
{
List<Component> compList = new ArrayList<Component>();
for (Component comp : c.getComponents()) {
compList.add(comp);
if (comp instanceof Container)
compList.addAll(getAllComponents((Container) comp));
}
return compList;
}
}
Loading

0 comments on commit 9ca046c

Please sign in to comment.