Changeset 91

Show
Ignore:
Timestamp:
29/12/07 18:56:49 (11 months ago)
Author:
altglass
Message:

Bugfixes, code improvements, resources can be cloned, mime-type fixes in SVN repository

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vlcskineditor/Main.java

    r88 r91  
    3333import javax.swing.border.*; 
    3434import java.util.zip.*; 
    35 import javax.imageio.*; 
    36 import vlcskineditor.resources.Bitmap; 
     35import javax.imageio.*;  
    3736import vlcskineditor.items.*; 
    3837import com.ice.tar.*; 
    3938import com.ice.jni.registry.*; 
    4039import vlcskineditor.history.*; 
     40import vlcskineditor.resources.Bitmap; 
     41import vlcskineditor.resources.SubBitmap; 
    4142 
    4243 
     
    6263  JTree res_tree,win_tree,items_tree;   
    6364  DefaultTreeModel res_tree_model, win_tree_model, items_tree_model; 
    64   JButton res_add_bitmap, res_add_font, res_edit, res_del; 
     65  JButton res_add_bitmap, res_add_font, res_duplicate, res_edit, res_del; 
    6566  JPopupMenu res_add_bitmap_pu; 
    6667  JMenuItem res_add_bitmap_pu_b, res_add_bitmap_pu_s; 
     
    7879  public ImageIcon add_bitmap_icon = createIcon("icons/add_bitmap.png");   
    7980  public ImageIcon add_font_icon = createIcon("icons/add_font.png"); 
     81  public ImageIcon copy_icon = createIcon("icons/copy.png"); 
    8082  public ImageIcon edit_icon = createIcon("icons/edit.png"); 
    8183  public ImageIcon edit_undo_icon = createIcon("icons/edit-undo.png"); 
     
    268270    res_add_font.setPreferredSize(new Dimension(24,24)); 
    269271    res_add_font.addActionListener(this); 
     272    res_duplicate = new JButton("",copy_icon); 
     273    res_duplicate.setToolTipText("Create copy of the selected item"); 
     274    res_duplicate.setPreferredSize(new Dimension(24,24)); 
     275    res_duplicate.addActionListener(this); 
    270276    res_edit = new JButton("",edit_icon); 
    271277    res_edit.setToolTipText("Edit the selected item"); 
     
    280286    resources.add(res_add_bitmap); 
    281287    resources.add(res_add_font); 
     288    resources.add(res_duplicate); 
    282289    resources.add(res_edit); 
    283290    resources.add(res_del);         
     
    287294    res_layout.putConstraint(SpringLayout.NORTH, res_add_bitmap,5,SpringLayout.SOUTH, res_tree_sp); 
    288295    res_layout.putConstraint(SpringLayout.NORTH, res_add_font,5,SpringLayout.SOUTH, res_tree_sp); 
     296    res_layout.putConstraint(SpringLayout.NORTH, res_duplicate,5,SpringLayout.SOUTH, res_tree_sp); 
    289297    res_layout.putConstraint(SpringLayout.NORTH, res_edit,5,SpringLayout.SOUTH, res_tree_sp); 
    290298    res_layout.putConstraint(SpringLayout.NORTH, res_del,5,SpringLayout.SOUTH, res_tree_sp);     
     
    295303    res_layout.putConstraint(SpringLayout.WEST, res_add_bitmap,5,SpringLayout.WEST, resources.getContentPane()); 
    296304    res_layout.putConstraint(SpringLayout.WEST, res_add_font,5,SpringLayout.EAST, res_add_bitmap); 
    297     res_layout.putConstraint(SpringLayout.WEST, res_edit,5,SpringLayout.EAST, res_add_font); 
     305    res_layout.putConstraint(SpringLayout.WEST, res_duplicate,5,SpringLayout.EAST, res_add_font); 
     306    res_layout.putConstraint(SpringLayout.WEST, res_edit,5,SpringLayout.EAST, res_duplicate); 
    298307    res_layout.putConstraint(SpringLayout.WEST, res_del,5,SpringLayout.EAST, res_edit);     
    299308    res_layout.putConstraint(SpringLayout.SOUTH, resources.getContentPane(),24+5+5,SpringLayout.SOUTH, res_tree_sp); 
     
    971980        Resource r = s.getResource(selected_resource); 
    972981        if(r!=null) { 
    973           if(r.type.equals("Bitmap")) { 
    974             vlcskineditor.resources.Bitmap b = (vlcskineditor.resources.Bitmap)r; 
     982          if(r.getClass()==Bitmap.class) { 
     983            Bitmap b = (Bitmap)r; 
     984            b.SubBitmaps.add(new vlcskineditor.resources.SubBitmap(s,b));   
     985          } 
     986          else if(r.getClass()==SubBitmap.class) { 
     987            SubBitmap sb = (SubBitmap)r; 
     988            Bitmap b = sb.getParentBitmap(); 
    975989            b.SubBitmaps.add(new vlcskineditor.resources.SubBitmap(s,b));   
    976990          } 
    977991          else { 
    978             JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add sub bitmap",JOptionPane.INFORMATION_MESSAGE); 
     992            JOptionPane.showMessageDialog(this,"The selected resource is no bitmap!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 
    979993          } 
    980994        } 
    981995        else { 
    982           JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add sub bitmap",JOptionPane.INFORMATION_MESSAGE); 
     996          JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 
    983997        } 
    984998      } 
    985999      else { 
    986         JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add sub bitmap",JOptionPane.INFORMATION_MESSAGE); 
     1000        JOptionPane.showMessageDialog(this,"No parent bitmap selected!","Could not add subbitmap",JOptionPane.INFORMATION_MESSAGE); 
    9871001      } 
    9881002    } 
     
    10061020        s.updateResources(); 
    10071021      }     
     1022    } 
     1023    // </editor-fold> 
     1024    // <editor-fold defaultstate="collapsed" desc="Duplicate resource"> 
     1025    else if(e.getSource().equals(res_duplicate)) { 
     1026      if(selected_resource==null) return; 
     1027      Resource r = s.getResource(selected_resource); 
     1028      if(r==null) return; 
     1029      if(r.getClass()==Bitmap.class) { 
     1030        Bitmap b = (Bitmap)r;         
     1031        Bitmap b2 = new Bitmap(b.returnCode(),s); 
     1032        b2.renameForCopy(); 
     1033        s.resources.add(b2); 
     1034        s.updateResources(); 
     1035        s.expandResource(b.id); 
     1036      } 
     1037      else if(r.getClass()==SubBitmap.class) { 
     1038        SubBitmap sb = (SubBitmap)r;         
     1039        SubBitmap sb2 = new SubBitmap(sb.returnCode(),s,sb.getParentBitmap()); 
     1040        sb2.renameForCopy(); 
     1041        sb.getParentBitmap().SubBitmaps.add(sb2); 
     1042        s.updateResources(); 
     1043        s.expandResource(sb.id); 
     1044      } 
     1045      else { 
     1046        vlcskineditor.resources.Font f = (vlcskineditor.resources.Font)r;         
     1047        vlcskineditor.resources.Font f2 = new vlcskineditor.resources.Font(f.returnCode(),s); 
     1048        f2.renameForCopy(); 
     1049        s.resources.add(f2); 
     1050        s.updateResources(); 
     1051        s.expandResource(f.id); 
     1052      } 
    10081053    } 
    10091054    // </editor-fold> 
  • trunk/src/vlcskineditor/Resource.java

    r71 r91  
    5050    return null; 
    5151  } 
     52  /** Renames the Resource after the copy process **/ 
     53  public void renameForCopy() { 
     54    if(id.indexOf("_copy")!=-1) { 
     55      id = id.substring(0,id.indexOf("_copy")); 
     56    }  
     57    String newid_base = id+="_copy";      
     58    String newid = newid_base; 
     59    int i = 1; 
     60    while(s.idExists(newid)) { 
     61      i++; 
     62      newid = newid_base+"_"+String.valueOf(i); 
     63    } 
     64    id = newid; 
     65  } 
    5266} 
  • trunk/src/vlcskineditor/Skin.java

    r89 r91  
    372372  /** Checks whether an id exists already **/ 
    373373  public boolean idExists(String id) { 
    374     for (int i=0;i<resources.size();i++) { 
    375       if(resources.get(i).id.equals(id)) return true; 
    376     } 
    377     for (int i=0;i<windows.size();i++) { 
    378       if(windows.get(i).id.equals(id)) return true; 
    379       for (int l=0;l<windows.get(i).layouts.size();l++) { 
    380         if(windows.get(i).layouts.get(l).id.equals(id)) return true; 
    381         for(int x=0;x<windows.get(i).layouts.get(l).items.size();x++) { 
    382           if(windows.get(i).layouts.get(l).items.get(x).id.equals(id)) return true; 
     374    if(getResource(id)!=null) return true; 
     375    for(Window w:windows) { 
     376      if(w.id.equals(id)) return true; 
     377      for(Layout l:w.layouts) { 
     378        if(l.id.equals(id)) return true; 
     379        if(l.getItem(id)!=null) return true; 
     380      } 
     381    } 
     382    return false; 
     383  } 
     384  /** Returns the resource represented by the given id **/ 
     385  public Resource getResource(String id) {     
     386    for (Resource r:resources) { 
     387      if(r.id.equals(id)) return r; 
     388      if(r.getClass()==Bitmap.class) { 
     389        Bitmap bmp = (Bitmap)r; 
     390        for(SubBitmap s:bmp.SubBitmaps) { 
     391          if(s.id.equals(id)) return s; 
    383392        } 
    384393      } 
    385394    } 
    386     return false; 
    387   } 
    388   /** Returns the resource represented by the given id **/ 
    389   public Resource getResource(String id) { 
    390     Resource r = null; 
    391     for (int i=0;i<resources.size();i++) { 
    392       if(resources.get(i).id.equals(id)) r=resources.get(i); 
    393       if(resources.get(i).type.equals("Bitmap")) { 
    394         Bitmap bmp = (Bitmap)resources.get(i); 
    395         for(int x=0;x<bmp.SubBitmaps.size();x++) { 
    396           if(bmp.SubBitmaps.get(x).id.equals(id)) r=bmp.SubBitmaps.get(x); 
    397         } 
    398       } 
    399     } 
    400     return r; 
     395    return null; 
    401396  } 
    402397  /** Returns the image object of a bitmap **/ 
     
    407402    } 
    408403    else { 
    409       if(r.type.equals("Bitmap")) { 
    410         try { 
    411           Bitmap b = (Bitmap)r; 
    412           return b.image; 
    413         } 
    414         catch(Exception e) { 
    415           try { 
    416             SubBitmap sb = (SubBitmap)r; 
    417             return sb.image; 
    418           } 
    419           catch(Exception e2) { 
    420              
    421           } 
    422         }         
     404      if(r.getClass()==Bitmap.class) {         
     405        Bitmap b = (Bitmap)r; 
     406        return b.image;         
     407      } 
     408      else if(r.getClass()==SubBitmap.class) { 
     409        SubBitmap sb = (SubBitmap)r; 
     410        return sb.image; 
    423411      } 
    424412      else return null; 
    425413    } 
    426     return null; 
    427414  } 
    428415  public java.awt.Font getFont(String id) { 
     
    433420    if(r==null) return (new java.awt.Font(java.awt.Font.SANS_SERIF,java.awt.Font.PLAIN,12)); 
    434421    try { 
    435       if(r.type.equals("Font")) { 
     422      if(r.getClass()==vlcskineditor.resources.Font.class) { 
    436423        vlcskineditor.resources.Font fr = (vlcskineditor.resources.Font)r; 
    437424        return fr.f; 
     
    506493    DefaultMutableTreeNode bitmaps_node = new DefaultMutableTreeNode("Root: Bitmaps"); 
    507494    DefaultMutableTreeNode fonts_node = new DefaultMutableTreeNode("Root: Fonts"); 
    508     for(int i=0;i<resources.size();i++) { 
    509       if(resources.get(i).type=="Bitmap") { 
    510         bitmaps_node.add(resources.get(i).getTreeNode()); 
    511       } 
    512     } 
    513     for(int i=0;i<resources.size();i++) { 
    514       if(resources.get(i).type=="Font") { 
    515         DefaultMutableTreeNode node = resources.get(i).getTreeNode();        
     495    for(Resource r:resources) { 
     496      if(r.getClass()==Bitmap.class) { 
     497        bitmaps_node.add(r.getTreeNode()); 
     498      } 
     499    } 
     500    for(Resource r:resources) { 
     501      if(r.getClass()==vlcskineditor.resources.Font.class) { 
     502        DefaultMutableTreeNode node = r.getTreeNode();        
    516503        fonts_node.add(node); 
    517504      } 
  • trunk/src/vlcskineditor/icons/edit-redo.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/edit-undo.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/editor.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/exit.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/help.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/items.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/new.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/open.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/preview.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/resources.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/save.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sliderbg_btt.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/icons/sliderbg_ltr.png

    • Property svn:mime-type changed from application/octet-stream to image/png
  • trunk/src/vlcskineditor/resources/Bitmap.java

    r71 r91  
    376376    return null; 
    377377  } 
     378  @Override 
     379  public void renameForCopy() { 
     380    super.renameForCopy(); 
     381    for(SubBitmap sb:SubBitmaps) sb.renameForCopy(); 
     382  } 
    378383} 
  • trunk/src/vlcskineditor/resources/SubBitmap.java

    r87 r91  
    320320    return top; 
    321321  } 
     322  public Bitmap getParentBitmap() { 
     323    return parent; 
     324  } 
    322325} 
  • trunk/src/vlcskineditor/resources/SubBitmapEditWindow.java

    r90 r91  
    9191  public void paint(Graphics g) {     
    9292    if(b.image==null) return; 
    93     if(drawcount>=40) drawcount = 0; 
     93    if(drawcount>=30) drawcount = 0; 
    9494    g.clearRect(0,0,getWidth(),getHeight()); 
    95     g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame); 
    96     //g.drawImage(b.image,0,0,frame); 
     95    g.drawImage(b.image, 0, 0, p_width*z_fact, p_height*z_fact, frame);     
    9796    g.setColor(Color.RED); 
    9897    int[] x = new int[4];