Changeset a53bf3df2ee843c7dcbff98462aa9c06d33cf7c1

Show
Ignore:
Timestamp:
07/20/08 18:05:12 (1 month ago)
Author:
Christopher Jung <bktheg@web.de>
git-committer:
Christopher Jung <bktheg@web.de> 1216569912 +0200
git-parent:

[f76390b959038f5635e9e51ab381b567ff6d78d0]

git-author:
Sebastian Gift <Madison@gt-knm.de> 1216569912 +0200
Message:

[feature] Die Position und der Typ eines Schiffes koennen jetzt ebenfalls geaendert werden.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/net/driftingsouls/ds2/server/modules/admin/EditShip.java

    rbe48d2f ra53bf3d  
    2020 
    2121import java.util.HashMap; 
     22import java.util.List; 
    2223import java.util.Map; 
    2324 
     
    3435import net.driftingsouls.ds2.server.modules.AdminController; 
    3536import net.driftingsouls.ds2.server.ships.Ship; 
     37import net.driftingsouls.ds2.server.ships.ShipType; 
    3638import net.driftingsouls.ds2.server.ships.ShipTypeData; 
    3739 
     
    4446public class EditShip implements AdminPlugin 
    4547{ 
     48        @SuppressWarnings("unchecked") 
    4649        public void output(AdminController controller, String page, int action) 
    4750        { 
     
    7477                                ship.setOwner(owner); 
    7578                        } 
     79                        ShipType type = (ShipType)db.get(ShipType.class, context.getRequest().getParameterInt("type")); 
     80                        if(type != null) 
     81                        { 
     82                                ship.setBaseType(type); 
     83                        } 
     84                        ship.setSystem(context.getRequest().getParameterInt("system")); 
     85                        ship.setX(context.getRequest().getParameterInt("x")); 
     86                        ship.setY(context.getRequest().getParameterInt("y")); 
    7687                        ship.setHull(context.getRequest().getParameterInt("hull")); 
    7788                        ship.setAblativeArmor(context.getRequest().getParameterInt("ablativearmor")); 
     
    121132                         
    122133                         
     134                        Map<Integer, String> shiptypes = new HashMap<Integer, String>(); 
     135                        List<ShipType> types = (List<ShipType>)db.createQuery("from ShipType").list(); 
     136                        for(ShipType shiptype: types) 
     137                        { 
     138                                shiptypes.put(shiptype.getId(), shiptype.getNickname()); 
     139                        } 
     140                         
     141                         
    123142                        echo.append("<form action=\"./ds\" method=\"post\">"); 
    124143                        echo.append("<table class=\"noBorder\" width=\"100%\">"); 
     
    130149                        echo.append("<tr><td class=\"noBorderS\">Name: </td><td><input type=\"text\" name=\"name\" value=\"" + ship.getName() + "\"></td></tr>\n"); 
    131150                        echo.append("<tr><td class=\"noBorderS\">Besitzer: </td><td><input type=\"text\" name=\"owner\" value=\"" + ship.getOwner().getId() + "\"></td><td class=\"noBorderS\">"+ Common._title(ship.getOwner().getNickname()) +"</td></tr>\n"); 
     151                        echo.append("<tr><td class=\"noBorderS\">System: </td><td><input type=\"text\" name=\"system\" value=\"" + ship.getSystem() + "\"></td></tr>\n"); 
     152                        echo.append("<tr><td class=\"noBorderS\">x: </td><td><input type=\"text\" name=\"x\" value=\"" + ship.getX() + "\"></td></tr>\n"); 
     153                        echo.append("<tr><td class=\"noBorderS\">y: </td><td><input type=\"text\" name=\"y\" value=\"" + ship.getY() + "\"></td></tr>\n"); 
     154                        echo.append("<tr><td class=\"noBorderS\">Schiffstyp: </td><td><select size=\"1\" name=\"type\" \">"); 
     155                        for(Map.Entry<Integer, String> shiptype: shiptypes.entrySet()) 
     156                        { 
     157                                echo.append("<option value=\""+ shiptype.getKey() +"\" " + (shiptype.getKey().equals(ship.getBaseType().getId()) ? "selected=\"selected\"" : "") + " />"+shiptype.getValue()+"</option>"); 
     158                        } 
     159                        echo.append("</select></td></tr>\n"); 
    132160                        echo.append("<tr><td class=\"noBorderS\">Huelle: </td><td><input type=\"text\" name=\"hull\" value=\"" + ship.getHull() + "\"></td><td class=\"noBorderS\">/ "+type.getHull()+"</td></tr>\n"); 
    133161                        echo.append("<tr><td class=\"noBorderS\">Ablative Panzerung: </td><td><input type=\"text\" name=\"ablativearmor\" value=\"" + ship.getAblativeArmor() + "\"></td><td class=\"noBorderS\">/ "+type.getAblativeArmor()+"</td></tr>\n");