Commit a4bc77fc authored by Daniel Dreibrodt's avatar Daniel Dreibrodt

Bug fixing and integration of SubBitmap and Font into the translation system

parent 5de95d2f
......@@ -109,6 +109,14 @@ ERROR_NBFRAMES_TITLE|Invalid number of frames
ERROR_NBFRAMES_MSG|The number of frames cannot be smaller than 1
ERROR_OTF_TITLE|OTF not supported
ERROR_OTF_MSG|You have chosen an OpenType font, VLC will display it correctly but the Skin Editor can not display it.\nYou will see another font in the preview.
ERROR_SIZE_INVALID_TITLE|Invalid size
ERROR_SIZE_INVALID_MSG|Please enter a valid size.
ERROR_WIDTH_INVALID_TITLE|Invalid width
ERROR_WIDTH_INVALID_MSG|Please enter a valid width.
ERROR_HEIGHT_INVALID_TITLE|Invalid heiht
ERROR_HEIGHT_INVALID_MSG|Please enter a valid height.
ERROR_OUTSIDE_TITLE|Dimensions not valid
ERROR_OUTSIDE_MSG|Specified dimensions are outside the parent bitmap!
#Other strings
THEMEINFO_NAME_DEFAULT|Unnamed Theme
......
......@@ -9,6 +9,8 @@ WIN_ITEM_ID|ID*:
WIN_ITEM_ID_TIP|Name and identificator of the %t. Must be unique.
WIN_ITEM_X|X:
WIN_ITEM_Y|Y:
WIN_ITEM_WIDTH|Width:
WIN_ITEM_HEIGHT|Height:
WIN_ITEM_VISIBLE|Visibility:
FILE_INDIR|in the same folder as the XML file
......@@ -27,6 +29,10 @@ WIN_BITMAP_FPS_TIP|Only used in animated bitmaps; it is the number of frames (im
WIN_BITMAP_ANIMATION|Animation attributes
WIN_BITMAP_CHOOSER_TITLE|Choose alphacolor
#SubBitmap
WIN_SBMP_TITLE|SubBitmap settings
WIN_SBMP_BOUNDS|Position and dimension attributes
#Font
WIN_FONT_TITLE|Font settings
WIN_FONT_FILE|File*:
......
......@@ -376,6 +376,7 @@ public class Layout implements ActionListener{
/**
* Handles the user interaction with the editing dialog.
*/
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) {
......@@ -388,11 +389,11 @@ public class Layout implements ActionListener{
return;
}
}
if(width_tf.getText().length()>0 && Integer.parseInt(width_tf.getText())<=0) {
if(width_tf.getText().length()<1 || Integer.parseInt(width_tf.getText())<=0) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_WIDTH_INVALID_MSG"),Language.get("ERROR_WIDTH_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(height_tf.getText().length()>0 && Integer.parseInt(height_tf.getText())<=0) {
if(height_tf.getText().length()<1 || Integer.parseInt(height_tf.getText())<=0) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_HEIGHT_INVALID_MSG"),Language.get("ERROR_HEIGHT_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
......
......@@ -284,6 +284,7 @@ public class Window implements ActionListener{
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) {
......
......@@ -188,6 +188,7 @@ public class Bitmap extends ImageResource implements ActionListener{
}
return true;
}
@Override
public void update() {
BitmapEditEvent be = new BitmapEditEvent(this);
file=file_tf.getText();
......@@ -202,6 +203,7 @@ public class Bitmap extends ImageResource implements ActionListener{
be.setNew();
s.m.hist.addEvent(be);
}
@Override
public void showOptions() {
if(frame==null) {
frame = new JFrame(Language.get("WIN_BITMAP_TITLE"));
......@@ -366,6 +368,7 @@ public class Bitmap extends ImageResource implements ActionListener{
frame.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(file_btn)) {
if(fc==null) {
......@@ -431,6 +434,7 @@ public class Bitmap extends ImageResource implements ActionListener{
frame = null;
}
}
@Override
public String returnCode(String indent) {
String code = indent+"<Bitmap id=\""+id+"\" file=\""+file+"\"";
code+=" alphacolor=\""+alphacolor+"\"";
......@@ -448,6 +452,7 @@ public class Bitmap extends ImageResource implements ActionListener{
}
return code;
}
@Override
public DefaultMutableTreeNode getTreeNode() {
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Bitmap: "+id);
for(int i=0;i<SubBitmaps.size();i++) {
......
......@@ -123,19 +123,19 @@ public class Font extends Resource implements ActionListener{
f = f.deriveFont((float)size);
}
catch(Exception e) {
e.printStackTrace();
if(file.indexOf(".otf")==-1) {
//JOptionPane.showMessageDialog(frame,"Error while loading font file!\n Please choose another file\n","Font file not valid",JOptionPane.ERROR_MESSAGE);
//Font file corrupt
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);
//showOptions();
return false;
}
else {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OTF_MSG"),Language.get("ERROR_OTF_TITLE"),JOptionPane.INFORMATION_MESSAGE);
try {
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);
f = f.deriveFont(12);
f = java.awt.Font.createFont(java.awt.Font.TYPE1_FONT,new File(s.skinfolder+file));
f = f.deriveFont((float)size);
}
catch(Exception ex) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OTF_MSG"),Language.get("ERROR_OTF_TITLE"),JOptionPane.INFORMATION_MESSAGE);
ex.printStackTrace();
f = new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,size);
}
......@@ -296,6 +296,10 @@ public class Font extends Resource implements ActionListener{
JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(size_tf.getText().length()<1) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_SIZE_INVALID_MSG"),Language.get("ERROR_SIZE_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
update();
if(!updateFont()) JOptionPane.showMessageDialog(frame,Language.get("ERROR_FILE_INVALID_MSG"),Language.get("ERROR_FILE_INVALID_TITLE"),JOptionPane.ERROR_MESSAGE);
else {
......
......@@ -113,6 +113,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
public void updateImage() {
if(parent.image != null) image = parent.image.getSubimage(x,y,width,height);
}
@Override
public void update() {
if(!created) {
id=id_tf.getText();
......@@ -144,42 +145,43 @@ public class SubBitmap extends ImageResource implements ActionListener{
s.expandResource(id);
}
}
@Override
public void showOptions() {
if(frame==null) {
frame = new JFrame("Subbitmap settings");
frame = new JFrame(Language.get("WIN_SBMP_TITLE"));
frame.setResizable(false);
frame.setLayout(new FlowLayout());
if(!created) frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
JLabel id_l = new JLabel("ID*:");
JLabel id_l = new JLabel(Language.get("WIN_ITEM_ID"));
id_tf = new JTextField();
id_tf.setToolTipText("Identifiant of the font that will be used with controls..");
JLabel x_l = new JLabel("X:");
id_tf.setToolTipText(Language.get("WIN_ITEM_ID_TIP").replaceAll("%t",type));
JLabel x_l = new JLabel(Language.get("WIN_ITEM_X"));
x_tf = new JTextField();
x_tf.setDocument(new NumbersOnlyDocument(false));
JLabel y_l = new JLabel("Y:");
JLabel y_l = new JLabel(Language.get("WIN_ITEM_Y"));
y_tf = new JTextField();
y_tf.setDocument(new NumbersOnlyDocument(false));
JLabel width_l = new JLabel("Width:");
JLabel width_l = new JLabel(Language.get("WIN_ITEM_WIDTH"));
width_tf = new JTextField();
width_tf.setDocument(new NumbersOnlyDocument(false));
JLabel height_l = new JLabel("Height:");
JLabel height_l = new JLabel(Language.get("WIN_ITEM_HEIGHT"));
height_tf = new JTextField();
height_tf.setDocument(new NumbersOnlyDocument(false));
JLabel nbframes_l = new JLabel("Number of frames:");
JLabel nbframes_l = new JLabel(Language.get("WIN_BITMAP_NBFRAMES"));
nbframes_tf = new JTextField();
nbframes_tf.setDocument(new NumbersOnlyDocument(false));
nbframes_tf.setToolTipText("This attribute is needed to define animated bitmaps; it is the number of frames (images) contained in your animation. All the different frames are just images laid vertically in the bitmap.");
JLabel fps_l = new JLabel("Frames per second:");
nbframes_tf.setToolTipText(Language.get("WIN_BITMAP_NBFRAMES_TIP"));
JLabel fps_l = new JLabel(Language.get("WIN_BITMAP_FPS"));
fps_tf = new JTextField();
fps_tf.setDocument(new NumbersOnlyDocument(false));
fps_tf.setToolTipText("Only used in animated bitmaps; it is the number of frames (images) per seconds of the animation.");
ok_btn = new JButton("OK");
fps_tf.setToolTipText(Language.get("WIN_BITMAP_FPS_TIP"));
ok_btn = new JButton(Language.get("BUTTON_OK"));
ok_btn.addActionListener(this);
cancel_btn = new JButton("Cancel");
cancel_btn = new JButton(Language.get("BUTTON_CANCEL"));
cancel_btn.addActionListener(this);
help_btn = new JButton("Help");
help_btn = new JButton(Language.get("BUTTON_HELP"));
help_btn.addActionListener(this);
JLabel attr_l = new JLabel("* Attributes marked with a star must be specified.");
JLabel attr_l = new JLabel(Language.get("NOTE_STARRED"));
//Distance of textfields to WEST edge of container
Component[] labels = { id_l, x_l, y_l, width_l, height_l, nbframes_l, fps_l};
......@@ -191,7 +193,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
general.add(id_l);
general.add(id_tf);
id_tf.setPreferredSize(new Dimension(tf_wd,id_tf.getPreferredSize().height));
general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "General Attributes"));
general.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_ITEM_GENERAL")));
SpringLayout general_layout = new SpringLayout();
general.setLayout(general_layout);
general_layout.putConstraint(SpringLayout.NORTH, id_l, 5, SpringLayout.NORTH, general);
......@@ -215,7 +217,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
bounds.add(height_l);
bounds.add(height_tf);
height_tf.setPreferredSize(new Dimension(tf_wd,height_tf.getPreferredSize().height));
bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Position and Dimension Attributes"));
bounds.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_SBMP_BOUNDS")));
SpringLayout bounds_layout = new SpringLayout();
bounds.setLayout(bounds_layout);
bounds_layout.putConstraint(SpringLayout.NORTH, x_l, 5, SpringLayout.NORTH, bounds);
......@@ -254,7 +256,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
animation.add(nbframes_tf);
animation.add(fps_l);
animation.add(fps_tf);
animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Animation Attributes"));
animation.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), Language.get("WIN_BITMAP_ANIMATION")));
SpringLayout ani_layout = new SpringLayout();
animation.setLayout(ani_layout);
nbframes_tf.setPreferredSize(new Dimension(tf_wd,nbframes_tf.getPreferredSize().height));
......@@ -327,32 +329,33 @@ public class SubBitmap extends ImageResource implements ActionListener{
height_tf.addKeyListener(sbew);
frame.addWindowListener(sbew);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(ok_btn)) {
if(id_tf.getText().equals("")) {
JOptionPane.showMessageDialog(frame,"Please enter a valid ID!","ID not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_INVALID_MSG"),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
else if(!id_tf.getText().equals(id)) {
if(s.idExists(id_tf.getText())) {
JOptionPane.showMessageDialog(frame,"The ID \""+id_tf.getText()+"\" already exists, please choose another one.","ID not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame,Language.get("ERROR_ID_EXISTS_MSG").replaceAll("%i", id_tf.getText()),Language.get("ERROR_ID_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
}
if(Integer.parseInt(height_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,"height must be greater 0!","height not valid",JOptionPane.INFORMATION_MESSAGE);
if(width_tf.getText().length()<1 || Integer.parseInt(width_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_WIDTH_INVALID_MSG"),Language.get("ERROR_WIDTH_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(Integer.parseInt(height_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,"Height must be greater 0!","Height not valid",JOptionPane.INFORMATION_MESSAGE);
if(height_tf.getText().length()<1 || Integer.parseInt(height_tf.getText())<1) {
JOptionPane.showMessageDialog(frame,Language.get("ERROR_HEIGHT_INVALID_MSG"),Language.get("ERROR_HEIGHT_INVALID_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(Integer.parseInt(x_tf.getText())+Integer.parseInt(width_tf.getText())>parent.image.getWidth()) {
JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OUTSIDE_MSG"),Language.get("ERROR_OUTSIDE_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
if(Integer.parseInt(y_tf.getText())+Integer.parseInt(height_tf.getText())>parent.image.getHeight()) {
JOptionPane.showMessageDialog(frame,"Specified dimensions are outside the parent bitmap!","Dimension not valid",JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(frame,Language.get("ERROR_OUTSIDE_MSG"),Language.get("ERROR_OUTSIDE_TITLE"),JOptionPane.INFORMATION_MESSAGE);
return;
}
update();
......@@ -383,6 +386,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
sbew.frame = null;
sbew = null;
}
@Override
public String returnCode(String indent) {
String code=indent+"<SubBitmap id=\""+id+"\" x=\""+String.valueOf(x)+"\" y=\""+String.valueOf(y)+"\"";
code+=" height=\""+String.valueOf(height)+"\" width=\""+String.valueOf(width)+"\"";
......@@ -391,6 +395,7 @@ public class SubBitmap extends ImageResource implements ActionListener{
code+="/>\n";
return code;
}
@Override
public DefaultMutableTreeNode getTreeNode() {
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Bitmap: "+id);
return top;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment