mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-31 16:44:37 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed004f5cfc | ||
|
|
12ca21b9e4 | ||
|
|
f5c454807c | ||
|
|
6118fc39d8 |
@@ -1 +1 @@
|
|||||||
start "" "javaw.exe" -Xmx512M -cp "lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\ATCS_v0.4.1.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio
|
start "" "javaw.exe" -Xmx512M -cp "lib\jide-oss.jar;lib\ui.jar;lib\junit-4.10.jar;lib\json_simple-1.1.jar;lib\rsyntaxtextarea.jar;lib\prefuse.jar;lib\ATCS_v0.4.2.jar;lib\AndorsTrainer_v0.1.2.jar;lib\bsh-2.0b4.jar" com.gpl.rpg.atcontentstudio.ATContentStudio
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.4.1.jar:lib/prefuse.jar:lib/json_simple-1.1.jar:lib/jide-oss.jar:lib/ui.jar:lib/junit-4.10.jar:lib/rsyntaxtextarea.jar:lib/bsh-2.0b4.jar com.gpl.rpg.atcontentstudio.ATContentStudio
|
java -Xmx512M -cp lib/AndorsTrainer_v0.1.2.jar:lib/ATCS_v0.4.2.jar:lib/prefuse.jar:lib/json_simple-1.1.jar:lib/jide-oss.jar:lib/ui.jar:lib/junit-4.10.jar:lib/rsyntaxtextarea.jar:lib/bsh-2.0b4.jar com.gpl.rpg.atcontentstudio.ATContentStudio
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
!include MUI2.nsh
|
!include MUI2.nsh
|
||||||
|
|
||||||
!define VERSION "0.4.1"
|
!define VERSION "0.4.2"
|
||||||
!define JAVA_BIN "java"
|
!define JAVA_BIN "java"
|
||||||
|
|
||||||
Name "Andor's Trail Content Studio v${VERSION}"
|
Name "Andor's Trail Content Studio v${VERSION}"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import com.gpl.rpg.atcontentstudio.ui.WorkspaceSelector;
|
|||||||
public class ATContentStudio {
|
public class ATContentStudio {
|
||||||
|
|
||||||
public static final String APP_NAME = "Andor's Trail Content Studio";
|
public static final String APP_NAME = "Andor's Trail Content Studio";
|
||||||
public static final String APP_VERSION = "v0.4.1";
|
public static final String APP_VERSION = "v0.4.2";
|
||||||
|
|
||||||
public static boolean STARTED = false;
|
public static boolean STARTED = false;
|
||||||
public static StudioFrame frame = null;
|
public static StudioFrame frame = null;
|
||||||
|
|||||||
@@ -522,6 +522,13 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
return gde;
|
return gde;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NPC getNPCIgnoreCase(String id) {
|
||||||
|
NPC gde = createdContent.gameData.getNPCIgnoreCase(id);
|
||||||
|
if (gde == null) gde = alteredContent.gameData.getNPCIgnoreCase(id);
|
||||||
|
if (gde == null) gde = baseContent.gameData.getNPCIgnoreCase(id);
|
||||||
|
return gde;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNPCCount() {
|
public int getNPCCount() {
|
||||||
return createdContent.gameData.npcs.size() + baseContent.gameData.npcs.size();
|
return createdContent.gameData.npcs.size() + baseContent.gameData.npcs.size();
|
||||||
}
|
}
|
||||||
@@ -833,7 +840,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
int index = -1;
|
int index = -1;
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
NPC npc = getNPC(i);
|
NPC npc = getNPC(i);
|
||||||
if (spawngroup_id.equals(npc.spawngroup_id)) {
|
if (spawngroup_id.equalsIgnoreCase(npc.spawngroup_id)) {
|
||||||
for (NPC present : result) {
|
for (NPC present : result) {
|
||||||
if (present.id.equals(npc.id)) {
|
if (present.id.equals(npc.id)) {
|
||||||
alreadyAdded = true;
|
alreadyAdded = true;
|
||||||
@@ -851,7 +858,7 @@ public class Project implements ProjectTreeNode, Serializable {
|
|||||||
}
|
}
|
||||||
if (result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
//Fallback case. A single NPC does not declare a spawn group, but is referred by its ID in maps' spawn areas.
|
//Fallback case. A single NPC does not declare a spawn group, but is referred by its ID in maps' spawn areas.
|
||||||
NPC npc = getNPC(spawngroup_id);
|
NPC npc = getNPCIgnoreCase(spawngroup_id);
|
||||||
if (npc != null) result.add(npc);
|
if (npc != null) result.add(npc);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class Dialogue extends JSONElement {
|
|||||||
requirement.parent = this;
|
requirement.parent = this;
|
||||||
if (requirementJson.get("requireType") != null) requirement.type = RequirementType.valueOf((String) requirementJson.get("requireType"));
|
if (requirementJson.get("requireType") != null) requirement.type = RequirementType.valueOf((String) requirementJson.get("requireType"));
|
||||||
requirement.required_obj_id = (String) requirementJson.get("requireID");
|
requirement.required_obj_id = (String) requirementJson.get("requireID");
|
||||||
requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
|
if (requirementJson.get("value") != null) requirement.required_value = JSONElement.getInteger(Integer.parseInt(requirementJson.get("value").toString()));
|
||||||
if (requirementJson.get("negate") != null) requirement.negated = (Boolean) requirementJson.get("negate");
|
if (requirementJson.get("negate") != null) requirement.negated = (Boolean) requirementJson.get("negate");
|
||||||
requirement.state = State.parsed;
|
requirement.state = State.parsed;
|
||||||
reply.requirements.add(requirement);
|
reply.requirements.add(requirement);
|
||||||
|
|||||||
@@ -212,6 +212,16 @@ public class GameDataSet implements ProjectTreeNode, Serializable {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NPC getNPCIgnoreCase(String id) {
|
||||||
|
if (npcs == null) return null;
|
||||||
|
for (NPC gde : npcs) {
|
||||||
|
if (id.equalsIgnoreCase(gde.id)){
|
||||||
|
return gde;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Quest getQuest(String id) {
|
public Quest getQuest(String id) {
|
||||||
if (quests == null) return null;
|
if (quests == null) return null;
|
||||||
for (Quest gde : quests) {
|
for (Quest gde : quests) {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class SpawnArea extends MapObject {
|
|||||||
|
|
||||||
public int quantity = 1;
|
public int quantity = 1;
|
||||||
public int spawnchance = 10;
|
public int spawnchance = 10;
|
||||||
|
public boolean active = true;
|
||||||
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
public List<NPC> spawnGroup = new ArrayList<NPC>();
|
||||||
|
|
||||||
public SpawnArea(tiled.core.MapObject obj) {
|
public SpawnArea(tiled.core.MapObject obj) {
|
||||||
@@ -21,6 +22,9 @@ public class SpawnArea extends MapObject {
|
|||||||
if (obj.getProperties().getProperty("spawnchance") != null) {
|
if (obj.getProperties().getProperty("spawnchance") != null) {
|
||||||
this.spawnchance = Integer.parseInt(obj.getProperties().getProperty("spawnchance"));
|
this.spawnchance = Integer.parseInt(obj.getProperties().getProperty("spawnchance"));
|
||||||
}
|
}
|
||||||
|
if (obj.getProperties().getProperty("active") != null) {
|
||||||
|
this.active = Boolean.parseBoolean(obj.getProperties().getProperty("active"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,6 +71,9 @@ public class SpawnArea extends MapObject {
|
|||||||
if (spawnchance != 10) {
|
if (spawnchance != 10) {
|
||||||
tmxObject.getProperties().setProperty("spawnchance", Integer.toString(spawnchance));
|
tmxObject.getProperties().setProperty("spawnchance", Integer.toString(spawnchance));
|
||||||
}
|
}
|
||||||
|
if (!this.active) {
|
||||||
|
tmxObject.getProperties().setProperty("active", Boolean.toString(active));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -717,63 +717,67 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
JLabel label = ((JLabel)c);
|
JLabel label = ((JLabel)c);
|
||||||
Dialogue.Reward reward = (Dialogue.Reward)value;
|
Dialogue.Reward reward = (Dialogue.Reward)value;
|
||||||
|
|
||||||
if (reward.type != null) {
|
decorateRewardJLabel(label, reward);
|
||||||
String rewardObjDesc = null;
|
|
||||||
if( reward.reward_obj != null) {
|
|
||||||
rewardObjDesc = reward.reward_obj.getDesc();
|
|
||||||
} else if (reward.reward_obj_id != null) {
|
|
||||||
rewardObjDesc = reward.reward_obj_id;
|
|
||||||
}
|
|
||||||
switch (reward.type) {
|
|
||||||
case activateMapChangeArea:
|
|
||||||
label.setText("Activate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
|
||||||
break;
|
|
||||||
case actorCondition:
|
|
||||||
label.setText("Give actor condition "+rewardObjDesc+" for "+reward.reward_value+" turns");
|
|
||||||
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
|
||||||
break;
|
|
||||||
case alignmentChange:
|
|
||||||
label.setText("Change alignment for faction "+rewardObjDesc+" : "+reward.reward_value);
|
|
||||||
break;
|
|
||||||
case createTimer:
|
|
||||||
label.setText("Create timer "+rewardObjDesc);
|
|
||||||
break;
|
|
||||||
case deactivateMapChangeArea:
|
|
||||||
label.setText("Deactivate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
|
||||||
break;
|
|
||||||
case deactivateSpawnArea:
|
|
||||||
label.setText("Deactivate spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
|
||||||
break;
|
|
||||||
case dropList:
|
|
||||||
label.setText("Give contents of droplist "+rewardObjDesc);
|
|
||||||
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
|
||||||
break;
|
|
||||||
case giveItem:
|
|
||||||
label.setText("Give "+reward.reward_value+" "+rewardObjDesc);
|
|
||||||
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
|
||||||
break;
|
|
||||||
case questProgress:
|
|
||||||
label.setText("Give quest progress "+rewardObjDesc+":"+reward.reward_value);
|
|
||||||
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
|
||||||
break;
|
|
||||||
case removeSpawnArea:
|
|
||||||
label.setText("Remove all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
|
||||||
break;
|
|
||||||
case skillIncrease:
|
|
||||||
label.setText("Increase skill "+rewardObjDesc+" level");
|
|
||||||
break;
|
|
||||||
case spawnAll:
|
|
||||||
label.setText("Respawn all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
label.setText("New, undefined reward");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void decorateRewardJLabel(JLabel label, Dialogue.Reward reward) {
|
||||||
|
if (reward.type != null) {
|
||||||
|
String rewardObjDesc = null;
|
||||||
|
if( reward.reward_obj != null) {
|
||||||
|
rewardObjDesc = reward.reward_obj.getDesc();
|
||||||
|
} else if (reward.reward_obj_id != null) {
|
||||||
|
rewardObjDesc = reward.reward_obj_id;
|
||||||
|
}
|
||||||
|
switch (reward.type) {
|
||||||
|
case activateMapChangeArea:
|
||||||
|
label.setText("Activate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
break;
|
||||||
|
case actorCondition:
|
||||||
|
label.setText("Give actor condition "+rewardObjDesc+" for "+reward.reward_value+" turns");
|
||||||
|
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
||||||
|
break;
|
||||||
|
case alignmentChange:
|
||||||
|
label.setText("Change alignment for faction "+rewardObjDesc+" : "+reward.reward_value);
|
||||||
|
break;
|
||||||
|
case createTimer:
|
||||||
|
label.setText("Create timer "+rewardObjDesc);
|
||||||
|
break;
|
||||||
|
case deactivateMapChangeArea:
|
||||||
|
label.setText("Deactivate mapchange area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
break;
|
||||||
|
case deactivateSpawnArea:
|
||||||
|
label.setText("Deactivate spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
break;
|
||||||
|
case dropList:
|
||||||
|
label.setText("Give contents of droplist "+rewardObjDesc);
|
||||||
|
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
||||||
|
break;
|
||||||
|
case giveItem:
|
||||||
|
label.setText("Give "+reward.reward_value+" "+rewardObjDesc);
|
||||||
|
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
||||||
|
break;
|
||||||
|
case questProgress:
|
||||||
|
label.setText("Give quest progress "+rewardObjDesc+":"+reward.reward_value);
|
||||||
|
if (reward.reward_obj != null) label.setIcon(new ImageIcon(reward.reward_obj.getIcon()));
|
||||||
|
break;
|
||||||
|
case removeSpawnArea:
|
||||||
|
label.setText("Remove all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
break;
|
||||||
|
case skillIncrease:
|
||||||
|
label.setText("Increase skill "+rewardObjDesc+" level");
|
||||||
|
break;
|
||||||
|
case spawnAll:
|
||||||
|
label.setText("Respawn all monsters in spawnarea area "+rewardObjDesc+" on map "+reward.map_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
label.setText("New, undefined reward");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class RepliesListModel implements ListModel {
|
public static class RepliesListModel implements ListModel {
|
||||||
|
|
||||||
@@ -981,19 +985,23 @@ public class DialogueEditor extends JSONElementEditor {
|
|||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
if (c instanceof JLabel) {
|
if (c instanceof JLabel) {
|
||||||
((JLabel)c).setText(((Requirement)value).getDesc());
|
decorateRequirementJLabel((JLabel)c, (Requirement)value);
|
||||||
if (((Requirement)value).required_obj != null) {
|
|
||||||
if (((Requirement)value).required_obj.getIcon() != null) {
|
|
||||||
((JLabel)c).setIcon(new ImageIcon(((Requirement)value).required_obj.getIcon()));
|
|
||||||
}
|
|
||||||
} if (((Requirement)value).type == null) {
|
|
||||||
((JLabel)c).setText("New, undefined requirement.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void decorateRequirementJLabel(JLabel label, Requirement req) {
|
||||||
|
label.setText(req.getDesc());
|
||||||
|
if (req.required_obj != null) {
|
||||||
|
if (req.required_obj.getIcon() != null) {
|
||||||
|
label.setIcon(new ImageIcon(req.required_obj.getIcon()));
|
||||||
|
}
|
||||||
|
} if (req.type == null) {
|
||||||
|
label.setText("New, undefined requirement.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class DialogueFieldUpdater implements FieldUpdateListener {
|
public class DialogueFieldUpdater implements FieldUpdateListener {
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(JComponent source, Object value) {
|
public void valueChanged(JComponent source, Object value) {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree;
|
package com.gpl.rpg.atcontentstudio.ui.gamedataeditors.dialoguetree;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.Point;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
@@ -9,6 +13,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JToolTip;
|
||||||
|
import javax.swing.ToolTipManager;
|
||||||
|
|
||||||
import prefuse.Display;
|
import prefuse.Display;
|
||||||
import prefuse.Visualization;
|
import prefuse.Visualization;
|
||||||
import prefuse.action.ActionList;
|
import prefuse.action.ActionList;
|
||||||
@@ -42,7 +52,11 @@ import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
|||||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||||
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
import com.gpl.rpg.atcontentstudio.model.gamedata.NPC;
|
||||||
|
import com.gpl.rpg.atcontentstudio.model.gamedata.Requirement;
|
||||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.gamedataeditors.DialogueEditor;
|
||||||
|
import com.gpl.rpg.atcontentstudio.ui.map.TMXMapEditor.TMXReplacementViewer;
|
||||||
|
import com.jidesoft.swing.JideBoxLayout;
|
||||||
|
|
||||||
public class DialogueGraphView extends Display {
|
public class DialogueGraphView extends Display {
|
||||||
|
|
||||||
@@ -147,6 +161,7 @@ public class DialogueGraphView extends Display {
|
|||||||
setSize(500,500);
|
setSize(500,500);
|
||||||
pan(250, 250);
|
pan(250, 250);
|
||||||
setHighQuality(true);
|
setHighQuality(true);
|
||||||
|
addControlListener(new TooltipControl());
|
||||||
addControlListener(new DoubleClickControl());
|
addControlListener(new DoubleClickControl());
|
||||||
addControlListener(new WheelZoomControl());
|
addControlListener(new WheelZoomControl());
|
||||||
addControlListener(new ZoomControl());
|
addControlListener(new ZoomControl());
|
||||||
@@ -435,6 +450,90 @@ public class DialogueGraphView extends Display {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TooltipControl extends ControlAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void itemEntered(VisualItem item, MouseEvent e) {
|
||||||
|
if (item.get(TARGET) != null) {
|
||||||
|
tooltippedItem = item;
|
||||||
|
if (!tooltipActivated) {
|
||||||
|
setToolTipText("");
|
||||||
|
ToolTipManager.sharedInstance().registerComponent(DialogueGraphView.this);
|
||||||
|
ToolTipManager.sharedInstance().setEnabled(true);
|
||||||
|
tooltipActivated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void itemExited(VisualItem item, MouseEvent e) {
|
||||||
|
//Hides the tooltip...
|
||||||
|
ToolTipManager.sharedInstance().setEnabled(false);
|
||||||
|
ToolTipManager.sharedInstance().unregisterComponent(DialogueGraphView.this);
|
||||||
|
tooltipActivated = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JToolTip tt = null;
|
||||||
|
private VisualItem tooltippedItem = null;
|
||||||
|
private VisualItem lastTTItem = null;
|
||||||
|
private boolean tooltipActivated = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getToolTipLocation(MouseEvent event) {
|
||||||
|
return new Point(event.getX() + 5, event.getY() + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JToolTip createToolTip() {
|
||||||
|
if (tt == null) tt = super.createToolTip();
|
||||||
|
if (tooltippedItem == lastTTItem) {
|
||||||
|
return tt;
|
||||||
|
}
|
||||||
|
tt = super.createToolTip();
|
||||||
|
lastTTItem = tooltippedItem;
|
||||||
|
tt.setLayout(new BorderLayout());
|
||||||
|
JPanel content = new JPanel();
|
||||||
|
content.setLayout(new JideBoxLayout(content, JideBoxLayout.PAGE_AXIS));
|
||||||
|
JLabel label;
|
||||||
|
if (tooltippedItem != null) {
|
||||||
|
Object target = tooltippedItem.get(TARGET);
|
||||||
|
if (target != null) {
|
||||||
|
if (target instanceof Dialogue) {
|
||||||
|
Dialogue d = (Dialogue) target;
|
||||||
|
label = new JLabel(new ImageIcon(DefaultIcons.getDialogueIcon()));
|
||||||
|
label.setText(d.id);
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
if (tooltippedItem.get(REPLY) == null) {
|
||||||
|
if (d.rewards != null && !d.rewards.isEmpty()) {
|
||||||
|
for (Dialogue.Reward r : d.rewards) {
|
||||||
|
label = new JLabel();
|
||||||
|
DialogueEditor.decorateRewardJLabel(label, r);
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Object replObj = tooltippedItem.get(REPLY);
|
||||||
|
if (replObj instanceof Dialogue.Reply) {
|
||||||
|
Dialogue.Reply r = (Dialogue.Reply) replObj;
|
||||||
|
if (r.requirements != null && !r.requirements.isEmpty()) {
|
||||||
|
for (Requirement req : r.requirements) {
|
||||||
|
label = new JLabel();
|
||||||
|
DialogueEditor.decorateRequirementJLabel(label, req);
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tt.add(content, BorderLayout.CENTER);
|
||||||
|
tt.setPreferredSize(tt.getLayout().preferredLayoutSize(tt));
|
||||||
|
return tt;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.awt.event.KeyAdapter;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseMotionAdapter;
|
||||||
import java.awt.event.MouseMotionListener;
|
import java.awt.event.MouseMotionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -42,12 +43,14 @@ import javax.swing.JSpinner;
|
|||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
|
import javax.swing.JToolTip;
|
||||||
import javax.swing.JTree;
|
import javax.swing.JTree;
|
||||||
import javax.swing.ListModel;
|
import javax.swing.ListModel;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.Scrollable;
|
import javax.swing.Scrollable;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.ToolTipManager;
|
||||||
import javax.swing.event.ListDataEvent;
|
import javax.swing.event.ListDataEvent;
|
||||||
import javax.swing.event.ListDataListener;
|
import javax.swing.event.ListDataListener;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
@@ -143,6 +146,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
private JComboBox targetAreaCombo;
|
private JComboBox targetAreaCombo;
|
||||||
private JComboBox evaluateTriggerBox;
|
private JComboBox evaluateTriggerBox;
|
||||||
private JSpinner quantityField;
|
private JSpinner quantityField;
|
||||||
|
private JCheckBox activeForNewGame;
|
||||||
private JList npcList;
|
private JList npcList;
|
||||||
private SpawnGroupNpcListModel npcListModel;
|
private SpawnGroupNpcListModel npcListModel;
|
||||||
|
|
||||||
@@ -544,6 +548,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
} else if (selected instanceof SpawnArea) {
|
} else if (selected instanceof SpawnArea) {
|
||||||
areaField = addTextField(pane, "Spawn group ID: ", ((SpawnArea)selected).name, ((TMXMap)target).writable, listener);
|
areaField = addTextField(pane, "Spawn group ID: ", ((SpawnArea)selected).name, ((TMXMap)target).writable, listener);
|
||||||
quantityField = addIntegerField(pane, "Number of spawned NPCs: ", ((SpawnArea)selected).quantity, false, ((TMXMap)target).writable, listener);
|
quantityField = addIntegerField(pane, "Number of spawned NPCs: ", ((SpawnArea)selected).quantity, false, ((TMXMap)target).writable, listener);
|
||||||
|
activeForNewGame = addBooleanBasedCheckBox(pane, "Active in a new game: ", ((SpawnArea)selected).active, ((TMXMap)target).writable, listener);
|
||||||
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
npcListModel = new SpawnGroupNpcListModel((SpawnArea) selected);
|
||||||
npcList = new JList(npcListModel);
|
npcList = new JList(npcListModel);
|
||||||
npcList.setCellRenderer(new GDERenderer(true, ((TMXMap)target).writable));
|
npcList.setCellRenderer(new GDERenderer(true, ((TMXMap)target).writable));
|
||||||
@@ -687,7 +692,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
replacementSimulator.setLayout(new JideBoxLayout(replacementSimulator, JideBoxLayout.PAGE_AXIS));
|
replacementSimulator.setLayout(new JideBoxLayout(replacementSimulator, JideBoxLayout.PAGE_AXIS));
|
||||||
final JCheckBox walkableVisibleBox = new JCheckBox("Show \""+TMXMap.WALKABLE_LAYER_NAME+"\" layer.");
|
final JCheckBox walkableVisibleBox = new JCheckBox("Show \""+TMXMap.WALKABLE_LAYER_NAME+"\" layer.");
|
||||||
JPanel areasActivationPane = new JPanel();
|
JPanel areasActivationPane = new JPanel();
|
||||||
areasActivationPane.setLayout(new JideBoxLayout(areasActivationPane, JideBoxLayout.LINE_AXIS));
|
areasActivationPane.setLayout(new JideBoxLayout(areasActivationPane, JideBoxLayout.PAGE_AXIS));
|
||||||
TreeModel areasTreeModel = new ReplaceAreasActivationTreeModel();
|
TreeModel areasTreeModel = new ReplaceAreasActivationTreeModel();
|
||||||
final JTree areasTree = new JTree(areasTreeModel);
|
final JTree areasTree = new JTree(areasTreeModel);
|
||||||
areasTree.setEditable(false);
|
areasTree.setEditable(false);
|
||||||
@@ -697,10 +702,14 @@ public class TMXMapEditor extends Editor {
|
|||||||
final JToggleButton activate = new JToggleButton("Activate ReplaceArea(s)");
|
final JToggleButton activate = new JToggleButton("Activate ReplaceArea(s)");
|
||||||
areasActivationPane.add(activate, JideBoxLayout.VARY);
|
areasActivationPane.add(activate, JideBoxLayout.VARY);
|
||||||
final TMXReplacementViewer viewer = new TMXReplacementViewer((TMXMap)target);
|
final TMXReplacementViewer viewer = new TMXReplacementViewer((TMXMap)target);
|
||||||
|
JPanel activateAndViewPane = new JPanel();
|
||||||
|
activateAndViewPane.setLayout(new JideBoxLayout(activateAndViewPane, JideBoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
|
activateAndViewPane.add(areasActivationPane, JideBoxLayout.FIX);
|
||||||
|
activateAndViewPane.add(viewer, JideBoxLayout.VARY);
|
||||||
|
|
||||||
replacementSimulator.add(walkableVisibleBox, JideBoxLayout.FIX);
|
replacementSimulator.add(walkableVisibleBox, JideBoxLayout.FIX);
|
||||||
replacementSimulator.add(areasActivationPane, JideBoxLayout.FIX);
|
replacementSimulator.add(activateAndViewPane, JideBoxLayout.VARY);
|
||||||
replacementSimulator.add(viewer, JideBoxLayout.VARY);
|
|
||||||
|
|
||||||
walkableVisibleBox.setSelected(true);
|
walkableVisibleBox.setSelected(true);
|
||||||
walkableVisibleBox.addActionListener(new ActionListener() {
|
walkableVisibleBox.addActionListener(new ActionListener() {
|
||||||
@@ -739,11 +748,14 @@ public class TMXMapEditor extends Editor {
|
|||||||
areasTree.addTreeSelectionListener(new TreeSelectionListener() {
|
areasTree.addTreeSelectionListener(new TreeSelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(TreeSelectionEvent e) {
|
public void valueChanged(TreeSelectionEvent e) {
|
||||||
|
ReplaceArea oldHighlight = viewer.highlighted;
|
||||||
|
viewer.highlighted = null;
|
||||||
if (areasTree.getSelectionPaths() == null) return;
|
if (areasTree.getSelectionPaths() == null) return;
|
||||||
for (TreePath paths : areasTree.getSelectionPaths()) {
|
for (TreePath paths : areasTree.getSelectionPaths()) {
|
||||||
Object target = paths.getLastPathComponent();
|
Object target = paths.getLastPathComponent();
|
||||||
if (target instanceof ReplaceArea) {
|
if (target instanceof ReplaceArea) {
|
||||||
activate.setSelected(viewer.activeReplacements.get((ReplaceArea) target));
|
activate.setSelected(viewer.activeReplacements.get((ReplaceArea) target));
|
||||||
|
viewer.highlighted = (ReplaceArea)target;
|
||||||
} else if (target instanceof MapObjectGroup) {
|
} else if (target instanceof MapObjectGroup) {
|
||||||
for (MapObject obj : ((MapObjectGroup)target).mapObjects) {
|
for (MapObject obj : ((MapObjectGroup)target).mapObjects) {
|
||||||
activate.setSelected(true);
|
activate.setSelected(true);
|
||||||
@@ -754,7 +766,10 @@ public class TMXMapEditor extends Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (oldHighlight != viewer.highlighted) {
|
||||||
|
viewer.revalidate();
|
||||||
|
viewer.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1248,19 +1263,6 @@ public class TMXMapEditor extends Editor {
|
|||||||
return new Rectangle(obj.x, obj.y, 16, 16);
|
return new Rectangle(obj.x, obj.y, 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getClosestTileCorner(Point p) {
|
|
||||||
return new Point(getClosestMultiple(p.x, 32), getClosestMultiple(p.y, 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getClosestMultiple(int num, int ref) {
|
|
||||||
int rest = num % ref;
|
|
||||||
int result = num - rest;
|
|
||||||
if (rest >= ref / 2) {
|
|
||||||
result += ref;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TMXViewer(final TMXMap map, FieldUpdateListener listener) {
|
public TMXViewer(final TMXMap map, FieldUpdateListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
renderer = createRenderer(map.tmxMap);
|
renderer = createRenderer(map.tmxMap);
|
||||||
@@ -1420,27 +1422,7 @@ public class TMXMapEditor extends Editor {
|
|||||||
return paintSelected;
|
return paintSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawObject(MapObject object, Graphics2D g2d, Color color) {
|
private MapRenderer createRenderer(tiled.core.Map map) {
|
||||||
g2d.setPaint(color);
|
|
||||||
g2d.drawRect(object.x+1, object.y+1, object.w-3, object.h-3);
|
|
||||||
g2d.drawRect(object.x+2, object.y+2, object.w-5, object.h-5);
|
|
||||||
g2d.setPaint(color.darker().darker());
|
|
||||||
g2d.drawLine(object.x, object.y + object.h - 1, object.x + object.w - 1, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + object.w - 1, object.y, object.x + object.w - 1, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + 3, object.x + object.w - 4, object.y + 3);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + 3, object.x + 3, object.y + object.h - 4);
|
|
||||||
g2d.setPaint(color.brighter().brighter().brighter());
|
|
||||||
g2d.drawLine(object.x, object.y, object.x + object.w - 1, object.y);
|
|
||||||
g2d.drawLine(object.x, object.y, object.x, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + object.h - 4, object.x + object.w - 4, object.y + object.h - 4);
|
|
||||||
g2d.drawLine(object.x + object.w - 4, object.y + 3, object.x + object.w - 4, object.y + object.h - 4);
|
|
||||||
Image img = object.getIcon();
|
|
||||||
g2d.setColor(new Color(255, 255, 255, 120));
|
|
||||||
g2d.fillRect(object.x + 2, object.y + 2, img.getWidth(null), img.getHeight(null));
|
|
||||||
g2d.drawImage(object.getIcon(), object.x + 2, object.y + 2, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private MapRenderer createRenderer(tiled.core.Map map) {
|
|
||||||
switch (map.getOrientation()) {
|
switch (map.getOrientation()) {
|
||||||
case tiled.core.Map.ORIENTATION_ORTHOGONAL:
|
case tiled.core.Map.ORIENTATION_ORTHOGONAL:
|
||||||
return new OrthogonalRenderer(map);
|
return new OrthogonalRenderer(map);
|
||||||
@@ -1820,6 +1802,11 @@ public class TMXMapEditor extends Editor {
|
|||||||
SpawnArea area = (SpawnArea) selectedMapObject;
|
SpawnArea area = (SpawnArea) selectedMapObject;
|
||||||
area.quantity = (Integer) value;
|
area.quantity = (Integer) value;
|
||||||
}
|
}
|
||||||
|
} else if (source == activeForNewGame) {
|
||||||
|
if (selectedMapObject instanceof SpawnArea) {
|
||||||
|
SpawnArea area = (SpawnArea) selectedMapObject;
|
||||||
|
area.active = (Boolean) value;
|
||||||
|
}
|
||||||
} else if (source == requirementTypeCombo) {
|
} else if (source == requirementTypeCombo) {
|
||||||
if (selectedMapObject instanceof KeyArea) {
|
if (selectedMapObject instanceof KeyArea) {
|
||||||
KeyArea area = (KeyArea) selectedMapObject;
|
KeyArea area = (KeyArea) selectedMapObject;
|
||||||
@@ -1933,6 +1920,8 @@ public class TMXMapEditor extends Editor {
|
|||||||
private Map<String, List<ReplaceArea>> replacementsForLayer = new LinkedHashMap<String, List<ReplaceArea>>();
|
private Map<String, List<ReplaceArea>> replacementsForLayer = new LinkedHashMap<String, List<ReplaceArea>>();
|
||||||
public Map<ReplaceArea, Boolean> activeReplacements = new LinkedHashMap<ReplaceArea, Boolean>();
|
public Map<ReplaceArea, Boolean> activeReplacements = new LinkedHashMap<ReplaceArea, Boolean>();
|
||||||
|
|
||||||
|
private boolean tooltipActivated = true;
|
||||||
|
|
||||||
public TMXReplacementViewer(final TMXMap map) {
|
public TMXReplacementViewer(final TMXMap map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
renderer = createRenderer(map.tmxMap);
|
renderer = createRenderer(map.tmxMap);
|
||||||
@@ -1942,6 +1931,30 @@ public class TMXMapEditor extends Editor {
|
|||||||
setPreferredSize(renderer.getMapSize());
|
setPreferredSize(renderer.getMapSize());
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
|
||||||
|
addMouseMotionListener(new MouseMotionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
tooltippedTile.setLocation(e.getX() / 32, e.getY() / 32);
|
||||||
|
if (!((TMXMap)target).tmxMap.contains(tooltippedTile.x, tooltippedTile.y)) {
|
||||||
|
if (tooltipActivated) {
|
||||||
|
//Hides the tooltip...
|
||||||
|
ToolTipManager.sharedInstance().setEnabled(false);
|
||||||
|
ToolTipManager.sharedInstance().unregisterComponent(TMXReplacementViewer.this);
|
||||||
|
tooltipActivated = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!tooltipActivated) {
|
||||||
|
ToolTipManager.sharedInstance().registerComponent(TMXReplacementViewer.this);
|
||||||
|
ToolTipManager.sharedInstance().setEnabled(true);
|
||||||
|
tooltipActivated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ToolTipManager.sharedInstance().registerComponent(this);
|
||||||
|
setToolTipText("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -2059,25 +2072,6 @@ public class TMXMapEditor extends Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void drawObject(MapObject object, Graphics2D g2d, Color color) {
|
|
||||||
g2d.setPaint(color);
|
|
||||||
g2d.drawRect(object.x+1, object.y+1, object.w-3, object.h-3);
|
|
||||||
g2d.drawRect(object.x+2, object.y+2, object.w-5, object.h-5);
|
|
||||||
g2d.setPaint(color.darker().darker());
|
|
||||||
g2d.drawLine(object.x, object.y + object.h - 1, object.x + object.w - 1, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + object.w - 1, object.y, object.x + object.w - 1, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + 3, object.x + object.w - 4, object.y + 3);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + 3, object.x + 3, object.y + object.h - 4);
|
|
||||||
g2d.setPaint(color.brighter().brighter().brighter());
|
|
||||||
g2d.drawLine(object.x, object.y, object.x + object.w - 1, object.y);
|
|
||||||
g2d.drawLine(object.x, object.y, object.x, object.y + object.h - 1);
|
|
||||||
g2d.drawLine(object.x + 3, object.y + object.h - 4, object.x + object.w - 4, object.y + object.h - 4);
|
|
||||||
g2d.drawLine(object.x + object.w - 4, object.y + 3, object.x + object.w - 4, object.y + object.h - 4);
|
|
||||||
Image img = object.getIcon();
|
|
||||||
g2d.setColor(new Color(255, 255, 255, 120));
|
|
||||||
g2d.fillRect(object.x + 2, object.y + 2, img.getWidth(null), img.getHeight(null));
|
|
||||||
g2d.drawImage(object.getIcon(), object.x + 2, object.y + 2, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private OrthogonalRenderer createRenderer(tiled.core.Map map) {
|
private OrthogonalRenderer createRenderer(tiled.core.Map map) {
|
||||||
return new OrthogonalRenderer(map);
|
return new OrthogonalRenderer(map);
|
||||||
@@ -2114,8 +2108,123 @@ public class TMXMapEditor extends Editor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JLabel noTileGround = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||||
|
JLabel noTileObjects = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||||
|
JLabel noTileAbove = new JLabel(new ImageIcon(DefaultIcons.getNullifyImage().getScaledInstance(32, 32, Image.SCALE_DEFAULT)));
|
||||||
|
{
|
||||||
|
noTileGround.setPreferredSize(new Dimension(32, 32));
|
||||||
|
noTileObjects.setPreferredSize(new Dimension(32, 32));
|
||||||
|
noTileAbove.setPreferredSize(new Dimension(32, 32));
|
||||||
|
}
|
||||||
|
Point tooltippedTile = new Point();
|
||||||
|
JToolTip tt = null;
|
||||||
|
Point lastTTTile = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JToolTip createToolTip() {
|
||||||
|
if (tooltippedTile.equals(lastTTTile)) {
|
||||||
|
return tt;
|
||||||
|
}
|
||||||
|
if (!((TMXMap)target).tmxMap.contains(tooltippedTile.x, tooltippedTile.y)) {
|
||||||
|
return super.createToolTip();
|
||||||
|
}
|
||||||
|
tt = super.createToolTip();
|
||||||
|
lastTTTile = new Point(tooltippedTile);
|
||||||
|
tt.setLayout(new BorderLayout());
|
||||||
|
JPanel content = new JPanel();
|
||||||
|
content.setLayout(new JideBoxLayout(content, JideBoxLayout.PAGE_AXIS));
|
||||||
|
if (tooltippedTile != null) {
|
||||||
|
Image tile;
|
||||||
|
JLabel label;
|
||||||
|
|
||||||
|
if (above != null && above.getTileAt(tooltippedTile.x, tooltippedTile.y) != null) {
|
||||||
|
tile = above.getTileAt(tooltippedTile.x, tooltippedTile.y).getImage();
|
||||||
|
} else {
|
||||||
|
tile = null;
|
||||||
|
}
|
||||||
|
if (tile != null) {
|
||||||
|
label = new JLabel(new ImageIcon(tile));
|
||||||
|
label.setPreferredSize(new Dimension(32,32));
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
} else {
|
||||||
|
content.add(noTileAbove, JideBoxLayout.FIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objects != null && objects.getTileAt(tooltippedTile.x, tooltippedTile.y) != null) {
|
||||||
|
tile = objects.getTileAt(tooltippedTile.x, tooltippedTile.y).getImage();
|
||||||
|
} else {
|
||||||
|
tile = null;
|
||||||
|
}
|
||||||
|
if (tile != null) {
|
||||||
|
label = new JLabel(new ImageIcon(tile));
|
||||||
|
label.setPreferredSize(new Dimension(32,32));
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
} else {
|
||||||
|
content.add(noTileObjects, JideBoxLayout.FIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ground != null && ground.getTileAt(tooltippedTile.x, tooltippedTile.y) != null) {
|
||||||
|
tile = ground.getTileAt(tooltippedTile.x, tooltippedTile.y).getImage();
|
||||||
|
} else {
|
||||||
|
tile = null;
|
||||||
|
}
|
||||||
|
if (tile != null) {
|
||||||
|
label = new JLabel(new ImageIcon(tile));
|
||||||
|
label.setPreferredSize(new Dimension(32,32));
|
||||||
|
content.add(label, JideBoxLayout.FIX);
|
||||||
|
} else {
|
||||||
|
content.add(noTileGround, JideBoxLayout.FIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
content.add(new JLabel(tooltippedTile.x+", "+tooltippedTile.y), JideBoxLayout.FIX);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tt.add(content, BorderLayout.CENTER);
|
||||||
|
tt.setPreferredSize(tt.getLayout().preferredLayoutSize(tt));
|
||||||
|
return tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Point getToolTipLocation(MouseEvent event) {
|
||||||
|
return event.getPoint();//new Point(event.getX() - (event.getX() % 32), event.getY() - (event.getY() % 32));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Point getClosestTileCorner(Point p) {
|
||||||
|
return new Point(getClosestMultiple(p.x, 32), getClosestMultiple(p.y, 32));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClosestMultiple(int num, int ref) {
|
||||||
|
int rest = num % ref;
|
||||||
|
int result = num - rest;
|
||||||
|
if (rest >= ref / 2) {
|
||||||
|
result += ref;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void drawObject(MapObject object, Graphics2D g2d, Color color) {
|
||||||
|
g2d.setPaint(color);
|
||||||
|
g2d.drawRect(object.x+1, object.y+1, object.w-3, object.h-3);
|
||||||
|
g2d.drawRect(object.x+2, object.y+2, object.w-5, object.h-5);
|
||||||
|
g2d.setPaint(color.darker().darker());
|
||||||
|
g2d.drawLine(object.x, object.y + object.h - 1, object.x + object.w - 1, object.y + object.h - 1);
|
||||||
|
g2d.drawLine(object.x + object.w - 1, object.y, object.x + object.w - 1, object.y + object.h - 1);
|
||||||
|
g2d.drawLine(object.x + 3, object.y + 3, object.x + object.w - 4, object.y + 3);
|
||||||
|
g2d.drawLine(object.x + 3, object.y + 3, object.x + 3, object.y + object.h - 4);
|
||||||
|
g2d.setPaint(color.brighter().brighter().brighter());
|
||||||
|
g2d.drawLine(object.x, object.y, object.x + object.w - 1, object.y);
|
||||||
|
g2d.drawLine(object.x, object.y, object.x, object.y + object.h - 1);
|
||||||
|
g2d.drawLine(object.x + 3, object.y + object.h - 4, object.x + object.w - 4, object.y + object.h - 4);
|
||||||
|
g2d.drawLine(object.x + object.w - 4, object.y + 3, object.x + object.w - 4, object.y + object.h - 4);
|
||||||
|
Image img = object.getIcon();
|
||||||
|
g2d.setColor(new Color(255, 255, 255, 120));
|
||||||
|
g2d.fillRect(object.x + 2, object.y + 2, img.getWidth(null), img.getHeight(null));
|
||||||
|
g2d.drawImage(object.getIcon(), object.x + 2, object.y + 2, null);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,10 @@ public class WorldMapEditor extends Editor {
|
|||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateXmlViewText(String text) {
|
||||||
|
editorPane.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel buildSegmentTab(final WorldmapSegment worldmap) {
|
private JPanel buildSegmentTab(final WorldmapSegment worldmap) {
|
||||||
JPanel pane = new JPanel();
|
JPanel pane = new JPanel();
|
||||||
|
|||||||
Reference in New Issue
Block a user