Gridarta Editor
AtrinikArchetypeSetCollectable.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.var.atrinik.model.collectable;
21 
22 import java.io.IOException;
23 import java.io.Writer;
31 import org.jetbrains.annotations.NotNull;
32 
39 public class AtrinikArchetypeSetCollectable extends AbstractArchetypeSetCollectable<GameObject, MapArchObject, Archetype> {
40 
44  @NotNull
46 
55  this.gameObjectParser = gameObjectParser;
56  }
57 
58  @Override
59  protected int collectArchetype(@NotNull final Archetype archetype, @NotNull final Writer out) throws IOException {
60  writeArchetype(out, archetype, true, gameObjectParser);
61 
62  // process the multi-part tails:
63  int result = 1;
64  for (Archetype tail = archetype.getMultiNext(); tail != null; tail = tail.getMultiNext()) {
65  result++;
66 
67  out.append("More\n");
68  writeArchetype(out, tail, false, gameObjectParser);
69  }
70 
71  return result;
72  }
73 
82  private static void writeArchetype(@NotNull final Appendable appendable, @NotNull final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> archetype, final boolean isHeadPart, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser) throws IOException {
83  appendable.append("Object ").append(archetype.getArchetypeName()).append('\n');
84 
85  if (archetype.getMultiShapeID() > 0) {
86  appendable.append("mpart_id ").append(Integer.toString(archetype.getMultiShapeID())).append('\n');
87  }
88  if (archetype.getMultiPartNr() > 0) {
89  appendable.append("mpart_nr ").append(Integer.toString(archetype.getMultiPartNr())).append('\n');
90  }
91 
92  if (archetype.getMsgText(false) != null) {
93  appendable.append("msg\n").append(archetype.getMsgText(false)).append("endmsg\n");
94  }
95 
96  if (isHeadPart) {
97  // special: add a string-attribute with the display-category
98  appendable.append("editor_folder ").append(archetype.getEditorFolder()).append('\n');
99  }
100 
101  appendable.append(archetype.getObjectText());
102 
103  if (isHeadPart) {
104  for (final GameObject inv : archetype) {
105  gameObjectParser.save(appendable, inv);
106  }
107  } else {
108  // position of multi relative to head
109  if (archetype.getMultiX() != 0) {
110  appendable.append("x ").append(Integer.toString(archetype.getMultiX())).append('\n');
111  }
112  if (archetype.getMultiY() != 0) {
113  appendable.append("y ").append(Integer.toString(archetype.getMultiY())).append('\n');
114  }
115  }
116 
117  appendable.append("end\n");
118  }
119 
120 }
net.sf.gridarta.model.collectable.AbstractArchetypeSetCollectable
Definition: AbstractArchetypeSetCollectable.java:47
net.sf.gridarta.model.collectable
Definition: AbstractArchetypeSetCollectable.java:20
net.sf.gridarta
net.sf
net.sf.gridarta.model.collectable.AbstractArchetypeSetCollectable.archetypeSet
final ArchetypeSet< G, A, R > archetypeSet
Definition: AbstractArchetypeSetCollectable.java:59
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.var
net.sf.gridarta.var.atrinik.IGUIConstants
Definition: IGUIConstants.java:31
net.sf.gridarta.var.atrinik.model.archetype.Archetype
Definition: Archetype.java:30
net.sf.gridarta.var.atrinik.model.collectable.AtrinikArchetypeSetCollectable.collectArchetype
int collectArchetype(@NotNull final Archetype archetype, @NotNull final Writer out)
Definition: AtrinikArchetypeSetCollectable.java:59
net
net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject
Definition: MapArchObject.java:39
net.sf.gridarta.var.atrinik
net.sf.gridarta.var.atrinik.model.collectable.AtrinikArchetypeSetCollectable.gameObjectParser
final GameObjectParser< GameObject, MapArchObject, Archetype > gameObjectParser
Definition: AtrinikArchetypeSetCollectable.java:45
net.sf.gridarta.var.atrinik.IGUIConstants.ARCH_FILE
String ARCH_FILE
Definition: IGUIConstants.java:67
net.sf.gridarta.var.atrinik.model.gameobject.GameObject
Definition: GameObject.java:44
net.sf.gridarta.var.atrinik.model.collectable.AtrinikArchetypeSetCollectable.AtrinikArchetypeSetCollectable
AtrinikArchetypeSetCollectable(@NotNull final ArchetypeSet< GameObject, MapArchObject, Archetype > archetypeSet, @NotNull final GameObjectParser< GameObject, MapArchObject, Archetype > gameObjectParser)
Definition: AtrinikArchetypeSetCollectable.java:53
net.sf.gridarta.model.archetypeset.ArchetypeSet
Definition: ArchetypeSet.java:37
net.sf.gridarta.model.io
Definition: AbstractArchetypeParser.java:20
net.sf.gridarta.var.atrinik.model.collectable.AtrinikArchetypeSetCollectable.writeArchetype
static void writeArchetype(@NotNull final Appendable appendable, @NotNull final net.sf.gridarta.model.archetype.Archetype< GameObject, MapArchObject, Archetype > archetype, final boolean isHeadPart, @NotNull final GameObjectParser< GameObject, MapArchObject, Archetype > gameObjectParser)
Definition: AtrinikArchetypeSetCollectable.java:82
net.sf.gridarta.var.atrinik.model.maparchobject
Definition: DefaultMapArchObjectFactory.java:20
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Definition: Archetype.java:41
net.sf.gridarta.var.atrinik.model
net.sf.gridarta.var.atrinik.model.gameobject
Definition: DefaultGameObjectFactory.java:20
net.sf.gridarta.model.io.GameObjectParser
Definition: GameObjectParser.java:37
net.sf.gridarta.model.archetypeset
Definition: ArchetypeSet.java:20
net.sf.gridarta.var.atrinik.model.collectable.AtrinikArchetypeSetCollectable
Definition: AtrinikArchetypeSetCollectable.java:39
net.sf.gridarta.var.atrinik.model.archetype
Definition: Archetype.java:20