Skip to content

Commit 9ca046c

Browse files
committed
Release of version v3.1
- Improvements to color changes while the tool is running. - Finalized the new file system.
1 parent 1bf8c41 commit 9ca046c

17 files changed

+860
-906
lines changed

settings.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<settings>
3-
<last-notes-file>H:\Gaming\Factorio\any%_Nefrums - Kopie.txt</last-notes-file>
3+
<last-notes-file>H:\Gaming\Factorio\any%_Nefrums_import.xml</last-notes-file>
44
<color-settings current="Dark">
55
<color-profile>
66
<name>Light</name>
@@ -16,9 +16,9 @@
1616
</color-profile>
1717
<color-profile>
1818
<name>Custom</name>
19-
<text>-1</text>
20-
<border>-1</border>
21-
<background>-1</background>
19+
<text>-16776961</text>
20+
<border>-16711936</border>
21+
<background>-65536</background>
2222
</color-profile>
2323
</color-settings>
2424
<hotkey-settings ctrl-workaround="true" current="">

src/edit/CellEditDialog.java

Lines changed: 476 additions & 383 deletions
Large diffs are not rendered by default.

src/edit/SectionManagerDialog.java

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@
1515
import logic.AddRemoveControl;
1616
import logic.MouseAdapters;
1717

18-
public class SectionManagerDialog
18+
public class SectionManagerDialog extends JDialog
1919
{
20-
public static JDialog sectionManagerDialog;
21-
public static JPanel sectionManagerPanel;
20+
/** Automatically generated secrialVerionUID */
21+
private static final long serialVersionUID = 4418008182269964040L;
22+
private static JPanel sectionManagerPanel;
2223

23-
public static void initializeSectionDialog()
24+
public SectionManagerDialog()
2425
{
25-
sectionManagerDialog = new JDialog(MainGui.window);
26-
sectionManagerDialog.setTitle("Section Manager");
27-
sectionManagerDialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
28-
sectionManagerDialog.setVisible(false);
26+
super(MainGui.window);
27+
this.setTitle("Section Manager");
28+
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
29+
this.setVisible(false);
2930
}
3031

31-
public static void updateSectionManagerDialog()
32+
public void updateSectionManagerDialog()
3233
{
33-
sectionManagerDialog.getContentPane().removeAll();
34+
this.getContentPane().removeAll();
3435

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

5858
section_index ++;
5959
gbc.gridy ++;
@@ -63,12 +63,25 @@ public static void updateSectionManagerDialog()
6363
inner_panel.add(AddRemoveControl.createAddSectionControl(section_index), gbc);
6464

6565
sectionManagerPanel.add(inner_panel);
66-
sectionManagerDialog.add(sectionManagerPanel);
66+
this.add(sectionManagerPanel);
6767

68-
sectionManagerDialog.pack();
69-
if (sectionManagerDialog.getHeight() > MainGui.screensize.height - 150)
70-
sectionManagerDialog.setPreferredSize(new Dimension(sectionManagerDialog.getWidth() + 20, MainGui.screensize.height - 150) );
71-
sectionManagerDialog.pack();
72-
sectionManagerDialog.setVisible(true);
68+
this.pack();
69+
if (this.getHeight() > MainGui.screensize.height - 150)
70+
this.setPreferredSize(new Dimension(this.getWidth() + 20, MainGui.screensize.height - 150) );
71+
this.pack();
72+
this.setVisible(true);
73+
}
74+
75+
public void updateLightingMode()
76+
{
77+
//TODO
78+
updateSectionManagerDialog();
79+
}
80+
81+
public void updateEditMode()
82+
{
83+
this.updateSectionManagerDialog();
84+
this.setVisible(MainGui.inEditMode);
85+
this.pack();
7386
}
7487
}

src/gui/Abbreviations.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.w3c.dom.Document;
2323
import org.w3c.dom.Element;
24+
import org.w3c.dom.NodeList;
2425

2526
import gui.MainGui;
2627
import logic.FileOperations;
@@ -164,7 +165,7 @@ public void mouseClicked(MouseEvent e)
164165
abbreviations_dialog.dispose();
165166
textfield_list.remove(row);
166167
abbr_list_copy.remove(abbr);
167-
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfiles(textfield_list) );
168+
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfields(textfield_list) );
168169
}
169170
} );
170171
gbc.gridx = 3;
@@ -201,7 +202,7 @@ public void mouseClicked(MouseEvent e)
201202
abbreviations_dialog.dispose();
202203
textfield_list.remove(new_row);
203204
abbr_list_copy.remove(new_abbr);
204-
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfiles(textfield_list) );
205+
showAbbreviationSettingsDialog(abbr_location, images_dir, getAbbreviationsListFromTextfields(textfield_list) );
205206
}
206207
} );
207208
gbc.gridx = 3;
@@ -233,7 +234,7 @@ public void mouseClicked(MouseEvent e)
233234
abbreviations_dialog.dispose();
234235
FileOperations.unsavedChanges = true;
235236
PopupAlerts.createMissingImagesMessage = true;
236-
setAbbreviationsList(getAbbreviationsListFromTextfiles(textfield_list) );
237+
setAbbreviationsList(getAbbreviationsListFromTextfields(textfield_list) );
237238
FileOperations.imagesDirectory = images_dir;
238239
FileOperations.fileAbbreviations = abbr_location;
239240
FileOperations.saveAbbereviationsFile();
@@ -260,7 +261,12 @@ public static void setAbbreviationsList(ArrayList<String[]> abbreviations_list)
260261
abbreviationsList = abbreviations_list.stream().sorted( (a,b) -> {return a[0].compareTo(b[0] ); } ).collect(Collectors.toCollection(ArrayList::new) );
261262
}
262263

263-
private static ArrayList<String[]> getAbbreviationsListFromTextfiles(ArrayList<JTextField[]> textfields)
264+
private static void sortAbbreviationList()
265+
{
266+
abbreviationsList = abbreviationsList.stream().sorted( (a,b) -> {return a[0].compareTo(b[0] ); } ).collect(Collectors.toCollection(ArrayList::new) );
267+
}
268+
269+
private static ArrayList<String[]> getAbbreviationsListFromTextfields(ArrayList<JTextField[]> textfields)
264270
{
265271
return textfields.stream().map(row -> new String[] {row[0].getText(), row[1].getText() } ).collect(Collectors.toCollection(ArrayList::new) );
266272
}
@@ -315,6 +321,15 @@ public static Element getAbbreviationsElement(Document doc)
315321

316322
public static void parseAbbreviationselement(Element abbreviaitons_element)
317323
{
324+
abbreviationsList.clear();
325+
326+
NodeList abbreviation_nodes = abbreviaitons_element.getElementsByTagName("abbreviation");
327+
for (int i = 0; i < abbreviation_nodes.getLength(); i ++)
328+
{
329+
Element abbr = (Element) abbreviation_nodes.item(i);
330+
abbreviationsList.add(new String[] {abbr.getElementsByTagName("abbr-short").item(0).getTextContent(), abbr.getElementsByTagName("abbr-long").item(0).getTextContent()} );
331+
}
318332

333+
sortAbbreviationList();
319334
}
320335
}

src/gui/ColorSettingProfile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public ColorSettingProfile(Element profile, String current_profile_name)
3030
ColorSettings.currentColorSetting = this;
3131
}
3232

33-
public void update(Color text, Color border, Color background)
33+
void update(Color text, Color border, Color background)
3434
{
3535
this.text = text;
3636
this.border = border;

src/gui/ColorSettings.java

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package gui;
22

33
import java.awt.Color;
4-
import java.awt.Component;
5-
import java.awt.Container;
64
import java.awt.Dimension;
75
import java.awt.GridBagConstraints;
86
import java.awt.GridBagLayout;
9-
import java.util.ArrayList;
10-
import java.util.List;
117

128
import javax.swing.BoxLayout;
139
import javax.swing.JButton;
@@ -16,12 +12,6 @@
1612
import javax.swing.JLabel;
1713
import javax.swing.JPanel;
1814
import javax.swing.JTextField;
19-
import javax.swing.border.MatteBorder;
20-
import javax.swing.border.TitledBorder;
21-
22-
import edit.CellEditDialog;
23-
import logic.Row;
24-
import logic.Section;
2515

2616
public class ColorSettings
2717
{
@@ -36,7 +26,7 @@ public class ColorSettings
3626
static void selectColorSettings(int index)
3727
{
3828
currentColorSetting = colorSettingProfiles[index];
39-
applyLightingMode();
29+
MainGui.updateLightingSettings();
4030
}
4131

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

130120
return res;
131121
}
132-
133-
static void applyLightingMode()
134-
{
135-
// backgrounds
136-
MainGui.window.setBackground(ColorSettings.getBackgroundColor() );
137-
MainGui.scrollPane.setBackground(ColorSettings.getBackgroundColor() );
138-
MainGui.mainPanel.setBackground(ColorSettings.getBackgroundColor() );
139-
140-
// text for cells
141-
for (JLabel label : MainGui.labelsText) label.setForeground(ColorSettings.getTextColor() );
142-
143-
// text for add-remove-controls
144-
for (JLabel label : MainGui.labelsTextsHideWhenNotInEdit) label.setForeground(MainGui.inEditMode ? ColorSettings.getTextColor() : ColorSettings.getBackgroundColor() );
145-
146-
// border color for sections
147-
for (Section section : MainGui.sectionsList)
148-
if (section.getBorder() != null)
149-
((TitledBorder) section.getBorder() ).setTitleColor(ColorSettings.getTextColor() );
150-
151-
// border for cells
152-
for (Section section : MainGui.sectionsList)
153-
for (Row row : section.getRows() )
154-
for (JPanel cell : row.getCells() )
155-
if (cell.getBorder() != null)
156-
cell.setBorder(new MatteBorder( ((MatteBorder) cell.getBorder() ).getBorderInsets(), ColorSettings.getBorderColor() ) );
157-
158-
// border for section label cells
159-
for (JLabel label : MainGui.sectionLabels)
160-
{
161-
label.setBorder(new MatteBorder( ((MatteBorder) label.getBorder() ).getBorderInsets(), ColorSettings.getBorderColor() ) );
162-
label.setForeground(ColorSettings.getTextColor() );
163-
}
164-
165-
// background and border for sectionManagerDialog
166-
if (edit.SectionManagerDialog.sectionManagerPanel!= null)
167-
{
168-
edit.SectionManagerDialog.sectionManagerPanel.setBackground(ColorSettings.getBackgroundColor() );
169-
edit.SectionManagerDialog.sectionManagerPanel.setBorder(new MatteBorder( ((MatteBorder) edit.SectionManagerDialog.sectionManagerPanel.getBorder() ).getBorderInsets(), ColorSettings.getTextColor() ) );
170-
}
171-
172-
// unpdate CellEditDialog
173-
CellEditDialog.updateColorSettings();
174-
}
175122

176123
static void changeCustomLightingSettings()
177124
{
@@ -221,16 +168,4 @@ static void changeCustomLightingSettings()
221168
options.setVisible(true);
222169
options.repaint();
223170
}
224-
225-
private static List<Component> getAllComponents(final Container c)
226-
{
227-
List<Component> compList = new ArrayList<Component>();
228-
for (Component comp : c.getComponents()) {
229-
compList.add(comp);
230-
if (comp instanceof Container)
231-
compList.addAll(getAllComponents((Container) comp));
232-
}
233-
return compList;
234-
}
235-
236171
}

src/gui/GuiHelper.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import java.awt.image.BufferedImage;
1111
import java.io.File;
1212
import java.io.IOException;
13+
import java.util.ArrayList;
14+
import java.util.List;
1315

1416
import javax.imageio.ImageIO;
1517
import javax.swing.BorderFactory;
@@ -46,7 +48,13 @@ public class GuiHelper
4648
*/
4749
public static TitledBorder getTitledBorderWithCorrectTextColor(String title)
4850
{
49-
TitledBorder border = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED), title);
51+
TitledBorder border = BorderFactory.createTitledBorder(
52+
BorderFactory.createEtchedBorder(
53+
EtchedBorder.RAISED//,
54+
//ColorSettings.getTextColor(),
55+
//ColorSettings.getBorderColor()
56+
),
57+
title);
5058
border.setTitleFont(MainGui.titleFont);
5159
border.setTitleColor(ColorSettings.getTextColor());
5260
return border;
@@ -60,7 +68,7 @@ public static TitledBorder getTitledBorderWithCorrectTextColor(String title)
6068
*/
6169
public static MatteBorder getSpacingBorder(int width)
6270
{
63-
return BorderFactory.createMatteBorder(width, width, width, width, ColorSettings.getBackgroundColor());
71+
return BorderFactory.createMatteBorder(width, width, width, width, ColorSettings.getBackgroundColor() );
6472
}
6573

6674
/**
@@ -402,4 +410,15 @@ private static ImageIcon getScaledLinebreakImageIcon()
402410
throw new RuntimeException("Error while loading 'Linebreak.png', file doesn't exist!");
403411
}
404412
}
413+
414+
public static List<Component> getAllComponents(final Container c)
415+
{
416+
List<Component> compList = new ArrayList<Component>();
417+
for (Component comp : c.getComponents()) {
418+
compList.add(comp);
419+
if (comp instanceof Container)
420+
compList.addAll(getAllComponents((Container) comp));
421+
}
422+
return compList;
423+
}
405424
}

0 commit comments

Comments
 (0)