Gridarta Editor
DaimoninArchetypeSetCollectable.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.daimonin.model.collectable;
21 
22 import java.io.IOException;
23 import java.io.Writer;
30 import org.jetbrains.annotations.NotNull;
31 
38 public class DaimoninArchetypeSetCollectable extends AbstractArchetypeSetCollectable<GameObject, MapArchObject, Archetype> {
39 
45  super(archetypeSet, IGUIConstants.ARCH_FILE);
46  }
47 
48  @Override
49  protected int collectArchetype(@NotNull final Archetype archetype, @NotNull final Writer out) throws IOException {
50  writeArchetype(out, archetype, true);
51 
52  // process the multi-part tails:
53  int result = 1;
54  for (Archetype tail = archetype.getMultiNext(); tail != null; tail = tail.getMultiNext()) {
55  result++;
56 
57  out.append("More\n");
58  writeArchetype(out, tail, false);
59  }
60 
61  return result;
62  }
63 
71  private static void writeArchetype(@NotNull final Appendable appendable, @NotNull final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> archetype, final boolean isHeadPart) throws IOException {
72  appendable.append("Object ").append(archetype.getArchetypeName()).append('\n');
73 
74  if (archetype.getMultiShapeID() > 0) {
75  appendable.append("mpart_id ").append(Integer.toString(archetype.getMultiShapeID())).append('\n');
76  }
77  if (archetype.getMultiPartNr() > 0) {
78  appendable.append("mpart_nr ").append(Integer.toString(archetype.getMultiPartNr())).append('\n');
79  }
80 
81  if (archetype.getMsgText() != null) {
82  appendable.append("msg\n").append(archetype.getMsgText()).append("endmsg\n");
83  }
84 
85  if (isHeadPart) {
86  // special: add a string-attribute with the display-category
87  appendable.append("editor_folder ").append(archetype.getEditorFolder()).append('\n');
88  }
89 
90  appendable.append(archetype.getObjectText());
91 
92  if (!isHeadPart) {
93  // position of multi relative to head
94  if (archetype.getMultiX() != 0) {
95  appendable.append("x ").append(Integer.toString(archetype.getMultiX())).append('\n');
96  }
97  if (archetype.getMultiY() != 0) {
98  appendable.append("y ").append(Integer.toString(archetype.getMultiY())).append('\n');
99  }
100  }
101 
102  appendable.append("end\n");
103  }
104 
105 }
Main package of Gridarta4Daimonin, contains all classes specific to the Daimonin version of the Grida...
Defines common UI constants used in different dialogs and all used icon files.
int collectArchetype(@NotNull final Archetype archetype, @NotNull final Writer out)
Base package of all Gridarta classes.
DaimoninArchetypeSetCollectable(@NotNull final ArchetypeSet< GameObject, MapArchObject, Archetype > archetypeSet)
Creates a new instance.
Abstract base class for Collectables that create the "archetypes" file.
MapArchObject contains the specific meta data about a map that is stored in the map-arch, at the very beginning of the map file.
Handles the Daimonin variants of GameObjects and Archetypes.
Implements the collection process that combines individual files into collected files which are read ...
final ArchetypeSet< G, A, R > archetypeSet
The ArchetypeSet being collected.
A net.sf.gridarta.model.collectable.Collectable that creates the Daimonin specific "archetypes" file...
Interface that captures similarities between different ArchetypeSet implementations.
static void writeArchetype(@NotNull final Appendable appendable, @NotNull final net.sf.gridarta.model.archetype.Archetype< GameObject, MapArchObject, Archetype > archetype, final boolean isHeadPart)
Writes an Archetype.