 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.dialog.replace;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Iterator;
25 import java.util.List;
37 import org.jetbrains.annotations.NotNull;
38 import org.jetbrains.annotations.Nullable;
62 public static <G extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>>
int replace(@NotNull
final MatchCriteria<G, A, R> matchCriteria,
final boolean entireMap,
final boolean deleteOnly,
final int replaceDensity, @NotNull
final MapView<G, A, R> mapView, @NotNull
final InsertionModeSet<G, A, R> insertionModeSet, @Nullable
final List<? extends
BaseObject<G, A, R, ?>> replaceList) {
63 final int replaceListSize = replaceList ==
null ? 0 : replaceList.size();
69 final Collection<G> objectsToReplace =
new ArrayList<>();
70 for (
final MapSquare<G, A, R> square : entireMap ? mapModel : mapView.getSelectedSquares()) {
74 objectsToReplace.clear();
75 for (
final G node : square) {
76 if (node.isHead() && matchCriteria.matches(node)) {
78 objectsToReplace.add(node);
84 for (
final G objectToReplace : objectsToReplace) {
85 final Iterator<G>
it = square.iterator();
88 while (
it.hasNext()) {
91 if (node == objectToReplace) {
102 if (replaceListSize > 0 && !deleteOnly) {
104 final G newGameObject;
112 if (newGameObject !=
null) {
113 newGameObject.propagateElevation(node);
G insertArchToMap(@NotNull BaseObject< G, A, R, ?> templateBaseObject, @Nullable G nextGameObject, @NotNull Point pos, boolean join)
Insert a game object to the map at a specified position.
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > int replace(@NotNull final MatchCriteria< G, A, R > matchCriteria, final boolean entireMap, final boolean deleteOnly, final int replaceDensity, @NotNull final MapView< G, A, R > mapView, @NotNull final InsertionModeSet< G, A, R > insertionModeSet, @Nullable final List<? extends BaseObject< G, A, R, ?>> replaceList)
A MapModel reflects the data of a map.
boolean isMulti()
Returns whether this Archetype is a multi-part object.
G insertBaseObject(@NotNull BaseObject< G, A, R, ?> baseObject, @NotNull Point pos, boolean allowMany, boolean join, @NotNull InsertionMode insertionMode)
Inserts a BaseObject to a map.
Criteria for game object matchers.
Base package of all Gridarta classes.
void endTransaction()
End a transaction.
void beginTransaction(@NotNull String name)
Starts a new transaction.
Point getMapLocation()
Returns the coordinate of this GameObject on its map.
Reflects a game object (object on a map).
Graphical User Interface of Gridarta.
GameObjects are the objects based on Archetypes found on maps.
static final Random RND
Global random number generator.
Interface for MapArchObjects.
A map view consists of a map grid and a map cursor, and is attached to a map control.
Base classes for rendering maps.
Utility class to replace objects in a map.
Currently nothing more than a marker interface for unification.
MapModel< G, A, R > getMapModel()
Returns the map model.
ReplaceUtils()
Private constructor to prevent instantiation.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it