Фикс сохранения и загрузки цветов
This commit is contained in:
parent
6f24631855
commit
e8ba3c4d51
@ -4,42 +4,52 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class ExtensionDrawingPlane {
|
public class ExtensionDrawingPlane {
|
||||||
public static DrawingPlane CreateDrawingPlane(String info, String separatorForObject, int width, int height) {
|
public static DrawingPlane CreateDrawingPlane(String info, String separatorForObject, int width, int height) {
|
||||||
|
// todo Добавить сохранение значеиня допкласса
|
||||||
String[] strs = info.split(separatorForObject);
|
String[] strs = info.split(separatorForObject);
|
||||||
if (strs.length == 3)
|
if (strs.length == 5) {
|
||||||
{
|
|
||||||
return new DrawingPlane(
|
return new DrawingPlane(
|
||||||
Integer.parseInt(strs[0]),
|
Integer.parseInt(strs[0]),
|
||||||
Integer.parseInt(strs[1]),
|
Integer.parseInt(strs[1]),
|
||||||
Color.getColor(strs[2]),
|
new Color(
|
||||||
|
Integer.parseInt(strs[2]),
|
||||||
|
Integer.parseInt(strs[3]),
|
||||||
|
Integer.parseInt(strs[4])
|
||||||
|
),
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (strs.length == 6)
|
if (strs.length == 10) {
|
||||||
{
|
|
||||||
return new DrawingStormtrooper(
|
return new DrawingStormtrooper(
|
||||||
Integer.parseInt(strs[0]),
|
Integer.parseInt(strs[0]),
|
||||||
Integer.parseInt(strs[1]),
|
Integer.parseInt(strs[1]),
|
||||||
Color.getColor(strs[2]),
|
new Color(
|
||||||
Color.getColor(strs[3]),
|
Integer.parseInt(strs[2]),
|
||||||
Boolean.parseBoolean(strs[4]),
|
Integer.parseInt(strs[3]),
|
||||||
Boolean.parseBoolean(strs[5]),
|
Integer.parseInt(strs[4])
|
||||||
|
),
|
||||||
|
new Color(
|
||||||
|
Integer.parseInt(strs[5]),
|
||||||
|
Integer.parseInt(strs[6]),
|
||||||
|
Integer.parseInt(strs[7])
|
||||||
|
),
|
||||||
|
Boolean.parseBoolean(strs[8]),
|
||||||
|
Boolean.parseBoolean(strs[9]),
|
||||||
width, height
|
width, height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static String GetDataForSave(DrawingPlane drawingPlane, String separatorForObject)
|
|
||||||
{
|
public static String GetDataForSave(DrawingPlane drawingPlane, String separatorForObject) {
|
||||||
|
// todo Добавить загрузку значеиня допкласса
|
||||||
var plane = drawingPlane.EntityPlane;
|
var plane = drawingPlane.EntityPlane;
|
||||||
if (plane == null)
|
if (plane == null) {
|
||||||
{
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
String str = plane.Speed + separatorForObject + plane.Weight + separatorForObject + plane.BodyColor.toString();
|
String str = plane.Speed + separatorForObject + plane.Weight + separatorForObject + plane.BodyColor.getRed() + separatorForObject + plane.BodyColor.getGreen() + separatorForObject + plane.BodyColor.getBlue();
|
||||||
if (!(plane instanceof EntityStormtrooper stormtrooper))
|
if (!(plane instanceof EntityStormtrooper stormtrooper)) {
|
||||||
{
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return str + separatorForObject + stormtrooper.AdditionalColor + separatorForObject + stormtrooper.Bombs + separatorForObject + stormtrooper.Rockets;
|
return str + separatorForObject + stormtrooper.AdditionalColor.getRed() + separatorForObject + stormtrooper.AdditionalColor.getGreen() + separatorForObject + stormtrooper.AdditionalColor.getBlue() + separatorForObject + stormtrooper.Bombs + separatorForObject + stormtrooper.Rockets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user