@Override
 public void load(Menu menu, BinaryFile bin, short version) {
   switch (version) {
     case 0:
       {
         name = bin.getString();
         anchor.load(bin);
         break;
       }
     case 1:
       {
         name = bin.getString();
         anchor.load(bin);
         if (bin.getBoolean()) {
           int layoutId = bin.getInt();
           layout = MenuComponentFactory.newLayoutInstance(layoutId, version, menu, bin);
         }
         int scriptCount = bin.getInt();
         scripts.ensureCapacity(scriptCount);
         for (int i = 0; i < scriptCount; i++) {
           scripts.add(bin.getString());
         }
         break;
       }
     default:
       throw new RuntimeException();
   }
 }
 @Override
 public void save(Menu menu, BinaryFile bin) {
   bin.addStringAllocated(name);
   anchor.save(bin);
   bin.allocateBytes(1 + (layout == null ? 0 : 4) + 4);
   bin.addBoolean(layout != null);
   if (layout != null) {
     bin.addInt(layout.getId());
     layout.saveLayout(menu, bin);
   }
   bin.addInt(scripts.size());
   for (String script : scripts) {
     bin.addStringAllocated(script);
   }
 }