Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Improvements, prep work for adding in Errata Items to repository #164

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions .gitignore
Expand Up @@ -9,8 +9,20 @@ Anathema*.zip
out/
.classpath
.project
/repository/
.settings/
*.launch
*.pdf
*.zip
*.zip
Thumbs.db

# Repository
repository.version
*.item
*.ecg
*.yap
*.xml

# Copied from /Development_Code/.cvsignore
/Development_Code/*.java
/Development_Code/*.pdf
/Development_Code/*.jasper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind that .gitignore just keeps stuff from getting picked up by git status or your gui tool. You can still explicitly add anything ignored here into git by using git add.

5 changes: 0 additions & 5 deletions Anathema/repository/.cvsignore

This file was deleted.

27 changes: 27 additions & 0 deletions Anathema/repository/equipment/Chopping_Sword.item
@@ -0,0 +1,27 @@
{
"statsByRuleSet": {
"SecondEdition": [
{
"accuracy": 1,
"damage": 4,
"damageTypeString": "Lethal",
"defence": -1,
"rate": 2,
"speed": 1,
"inflictsNoDamage": false,
"tags": [],
"minimumDamage": 1,
"name": "Close",
"type": "Melee Weapon"
}
]
},
"description": "2E Core p366, 2.5 Errata p15",
"name": "Chopping Sword",
"collectionFactory": {},
"composition": "None",
"cost": {
"costType": "Resources",
"costValue": 2
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single sample JSON item. I have the rest of the Errata items done, I just need to alter the build system to take them into account, then I'll add them into git.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and your (now removed) comment in the changelog, made me think:
How about adding a new bootjob that leverages the existing Database structure to write those items you want written?
That would take care of distribution and us inadvertently overwriting modified items in a single stroke.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be one way to handle distribution. I was envisioning just rolling them into the deployment process, so they'd just naturally appear in the repository/equipment folder on install. I admit, I did have a few lingering questions like: "What do we do when we want to update a "built in" item. Do we overwrite the item in the repository? What if the user has made customizations to the item?

I'm open to adding in the items if and only if the user has no existing database, but the only problem I see is that we still don't have an ordering system in place for bootjobs. So we can't rely on the Equipment.yap file already having been converted by the Databse bootjob. This new bootjob would have to know how to both check for JSON items in the repository, but also have to check for the Equipment.yap file. If neither of those items existed, it could extract the "default items".

1 change: 0 additions & 1 deletion Anathema/repository/music/.cvsignore

This file was deleted.

@@ -0,0 +1,45 @@
package net.sf.anathema.character.equipment.item;

import java.awt.Component;

import net.disy.commons.swing.action.SmartAction;
import net.sf.anathema.character.equipment.item.model.IEquipmentDatabaseManagement;
import net.sf.anathema.character.equipment.item.view.IEquipmentDatabaseView;
import net.sf.anathema.lib.control.objectvalue.IObjectValueChangedListener;
import net.sf.anathema.framework.presenter.resources.PlatformUI;
import net.sf.anathema.lib.gui.wizard.workflow.ICondition;
import net.sf.anathema.lib.resources.IResources;

public final class CopyEquipmentTemplateAction extends SmartAction {
private static final long serialVersionUID = -2131791434827503585L;
private final IEquipmentDatabaseManagement model;
private final IResources resources;

public CopyEquipmentTemplateAction(IResources resources, IEquipmentDatabaseManagement model) {
super(new PlatformUI(resources).getCopyIcon());
this.resources = resources;
this.model = model;
model.getTemplateEditModel().getDescription().getName().addTextChangedListener(new IObjectValueChangedListener<String>() {
public void valueChanged(String newValue) {
setEnabled(true);
}
});
setEnabled(true);
setToolTipText(resources.getString("Equipment.Creation.Item.CopyActionTooltip")); //$NON-NLS-1$
}

@Override
protected void execute(Component parentComponent) {
DiscardChangesVetor vetor = new DiscardChangesVetor(resources, new ICondition() {
public boolean isFulfilled() {
return model.getTemplateEditModel().isDirty();
}
}, parentComponent);
if (vetor.vetos()) {
return;
}
model.getTemplateEditModel().copyNewTemplate();
setEnabled(false);
}

}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New button to allow copying of an item in the equipment database.

Expand Up @@ -60,6 +60,7 @@ private String getColonString(String key) {

private void addEditTemplateActions() {
view.addEditTemplateAction(new NewEquipmentTemplateAction(resources, model));
view.addEditTemplateAction(new CopyEquipmentTemplateAction(resources, model));
view.addEditTemplateAction(new SaveEquipmentTemplateAction(resources, model));
view.addEditTemplateAction(new RemoveEquipmentTemplateAction(resources, model, view));
}
Expand Down
Expand Up @@ -17,6 +17,7 @@ public NewEquipmentTemplateAction(IResources resources, IEquipmentDatabaseManage
super(new PlatformUI(resources).getNewIcon());
this.resources = resources;
this.model = model;
setToolTipText(resources.getString("Equipment.Creation.Item.NewActionTooltip")); //$NON-NLS-1$
}

@Override
Expand Down
Expand Up @@ -30,6 +30,7 @@ public void valueChanged(String newValue) {
}
});
updateEnabled(view.getTemplateListView().getSelectedObject());
setToolTipText(resources.getString("Equipment.Creation.Item.RemoveActionTooltip")); //$NON-NLS-1$
}

private void updateEnabled(String string) {
Expand All @@ -38,7 +39,7 @@ private void updateEnabled(String string) {

@Override
protected void execute(Component parentComponent) {
String messageText = resources.getString("Equipment.Creation.DeleteMessage.Text"); //$NON-NLS-1$
String messageText = model.getTemplateEditModel().getEditTemplateId() + " - " + resources.getString("Equipment.Creation.DeleteMessage.Text"); //$NON-NLS-1$
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the name of the item you're deleting to the text in the popup box.

String okText = resources.getString("Equipment.Creation.DeleteMessage.OKButton"); //$NON-NLS-1$
ConfigurableVetor vetor = new ConfigurableVetor(parentComponent, messageText, okText);
if (vetor.vetos()) {
Expand Down
Expand Up @@ -37,6 +37,7 @@ public SaveEquipmentTemplateAction(IResources resources, IEquipmentDatabaseManag
model.getTemplateEditModel().addCostChangeListener(changeListener);
model.getTemplateEditModel().addMagicalMaterialChangeListener(changeListener);
updateEnabled();
setToolTipText(resources.getString("Equipment.Creation.Item.SaveActionTooltip")); //$NON-NLS-1$
}

private void updateEnabled() {
Expand Down
Expand Up @@ -29,6 +29,8 @@ public interface IEquipmentTemplateEditModel {
String getEditTemplateId();

void setNewTemplate();

void copyNewTemplate();

void setMagicalMaterial(MagicalMaterial newValue);

Expand Down
Expand Up @@ -13,6 +13,11 @@ Equipment.Creation.Stats=Stats
Equipment.Creation.Stats.AddActionTooltip=Add new stats
Equipment.Creation.Stats.EditActionTooltip=Edit selected stats

Equipment.Creation.Item.NewActionTooltip=Create new item
Equipment.Creation.Item.CopyActionTooltip=Copy this item
Equipment.Creation.Item.SaveActionTooltip=Save this item
Equipment.Creation.Item.RemoveActionTooltip=Delete this item
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New tooltips!


Equipment.Creation.UnsavedChangesMessage.Text=You have unsaved changes. Discard them?
Equipment.Creation.UnsavedChangesMessage.OKButton=Discard changes
Equipment.Creation.OverwriteMessage.Text=Really overwrite existing item?
Expand Down
Expand Up @@ -10,6 +10,11 @@ Equipment.Creation.Stats=Estadisticas
Equipment.Creation.Stats.EditActionTooltip=Editar las estadisticas seleccionadas
Equipment.Creation.Stats.AddActionTooltip=Agregar nuevas estadisticas

Equipment.Creation.Item.NewActionTooltip=Crear nuevo elemento
Equipment.Creation.Item.CopyActionTooltip=Copie este art�culo
Equipment.Creation.Item.SaveActionTooltip=Guardar este art�culo
Equipment.Creation.Item.RemoveActionTooltip=Eliminar este art�culo

Equipment.Creation.UnsavedChangesMessage.Text=Tienes cambios sin grabar. �Descartarlos?
Equipment.Creation.UnsavedChangesMessage.OKButton=Descartar cambios
Equipment.Creation.OverwriteMessage.Text=�Sobreescribir el articulo existente?
Expand Down
Expand Up @@ -12,6 +12,11 @@ Equipment.Creation.Stats=Statistice
Equipment.Creation.Stats.AddActionTooltip=Aggiungi nuova statistica
Equipment.Creation.Stats.EditActionTooltip=Edita statistica selezionata

Equipment.Creation.Item.NewActionTooltip=Crea nuovo elemento
Equipment.Creation.Item.CopyActionTooltip=Copia questo articolo
Equipment.Creation.Item.SaveActionTooltip=Salva questo articolo
Equipment.Creation.Item.RemoveActionTooltip=Eliminare questa voce

Equipment.Creation.UnsavedChangesMessage.Text=Non hai salvato i cambiamenti.Li Scarto?
Equipment.Creation.UnsavedChangesMessage.OKButton=Scarta cambiamenti
Equipment.Creation.OverwriteMessage.Text=Sicuro di voler sovrascrivere l'oggetto esistente?
Expand Down
Expand Up @@ -76,9 +76,18 @@ public void setNewTemplate() {
getDescription().getName().setText(null);
getDescription().getContent().setText(new ITextPart[0]);
setMaterialComposition(MaterialComposition.None);
setCost( new ItemCost("Resources",0) );
statses.clear();
fireStatsChangedEvent();
}

@Override
public void copyNewTemplate() {
editTemplateId += " copy";
getDescription().getName().setText(editTemplateId);

fireStatsChangedEvent();
}

@Override
public boolean isDirty() {
Expand Down

This file was deleted.

Expand Up @@ -54,7 +54,7 @@ public String[] getAllAvailableTemplateIds() {

@Override
public IEquipmentTemplate loadTemplate(String templateId) {
String id = new FilenameCleaner().clean(templateId);
String id = cleanFilename(templateId);
if (!access.exists(id)) {
return null;
}
Expand All @@ -73,6 +73,12 @@ public void saveTemplate(IEquipmentTemplate template) {
availableTemplatesChangeControl.fireChangedEvent();
}

public void saveTemplateNoOverwrite(IEquipmentTemplate template) {
if( loadTemplate( template.getName() ) == null ) {
saveTemplate( template );
}
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used only by the JSON conversion bootjob, just makes sure not to overwrite an existing item.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so the bootjob doesn't overwrite extracted-and-modified items when the user puts another .yap database into the folder, while the bootjob still relies on the version stored in the database file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is that during the bootjob process, after its loaded Equipment.yap into memory and is writing the items to file as JSON objects, it will check for an existing JSON Item_Name.item in the repository/equipment folder. If such an item exists, it won't save the version from Equipment.yap.

The idea was to add in all the 2.5 Errata items into git, and into the build process, so they'd extract during install to the repository/equipment folder.

See my comment at the end for more discussion on how to handle these 2.5 items.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is no longer necessary for handling overwriting of "default" items, I'd keep this in here simply because it handles an edge case: The user drops in somebody's Equipment.yap file in with their JSON items. With this in place, it will preserve their JSON items if they're the same name as the ones in the yap file. Without this, the yap contents would overwrite the JSON ones.

@Override
public void addAvailableTemplateChangeListener(IChangeListener listener) {
availableTemplatesChangeControl.addChangeListener(listener);
Expand All @@ -92,21 +98,25 @@ public void updateTemplate(String editTemplateId, IEquipmentTemplate saveTemplat
}

private void delete(String editTemplateId) {
String id = new FilenameCleaner().clean(editTemplateId);
String id = cleanFilename(editTemplateId);
if (access.exists(id)) {
access.delete(id);
}
}

private IEquipmentTemplate loadExistingTemplate(String templateId) {
String id = new FilenameCleaner().clean(templateId);
String id = cleanFilename(templateId);
String json = access.read(id);
return gson.fromJson(json);
}

private void save(IEquipmentTemplate template) {
String id = new FilenameCleaner().clean(template.getName());
String id = cleanFilename(template.getName());
String json = gson.toJson(template);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are static to avoid excess object creation.

access.write(id, json);
}

private String cleanFilename(String input) {
return input.replaceAll("\\W", "_");
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My replacement for the FilenameCleaner class

Expand Up @@ -70,7 +70,7 @@ private void convertToGson(IAnathemaModel anathemaModel, ObjectContainer contain
ObjectSet set = query.execute();
for (Object object : set) {
EquipmentTemplate template = (EquipmentTemplate) object;
database.saveTemplate(template);
database.saveTemplateNoOverwrite(template);
}
}

Expand Down
@@ -0,0 +1,18 @@
package net.sf.anathema.character.equipment.impl.module;

import net.sf.anathema.framework.IAnathemaModel;
import net.sf.anathema.framework.presenter.toolbar.IAnathemaTool;
import net.sf.anathema.framework.view.toolbar.IAnathemaToolbar;
import net.sf.anathema.initialization.Tool;
import net.sf.anathema.lib.resources.IResources;
import net.sf.anathema.platform.database.StartDatabaseAction;

@Tool
public class StartEquipmentDatabaseTool implements IAnathemaTool {

public void add(IResources resources, IAnathemaModel model, IAnathemaToolbar toolbar) {
toolbar.addSeparator();
EquipmentDatabaseActionProperties properties = new EquipmentDatabaseActionProperties(resources, model);
toolbar.addTools(StartDatabaseAction.createToolAction(resources, model, properties));
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure why nobody ever wrote this class. The backend work was mostly good to go, it just needed a tool action to add the Equipment Database to the toolbar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had tried to do so once before, but was thrown off when the resulting button appeared to the left of new/load/save functions, which looks a bit unnatural. We'd briefly discussed adding some means of determining sorting or priority, which I'd planned to look at eventually.

I suppose it doesn't really hurt to do now, though. :)

5 changes: 0 additions & 5 deletions Development_Code/.cvsignore

This file was deleted.

9 changes: 8 additions & 1 deletion Development_Documentation/Distribution/English/versions.txt
Expand Up @@ -13,6 +13,8 @@ http://anathema.github.com
From this version onward, Anathema no longer uses the "Equipment.yap" file, but individual files for each item.
It will convert existing databases and afterwards remove the .yap file.

This version of Anathema comes with the basic weapons, shields, and armor from the Errata. When converting your old database, it will not overwrite these items. If you choose to customize one of these included items, you will need to change the name to avoid it being overwritten in a future update.

-- Features --
* New preference: Allow equipment customization.
Allows to overwrite an item's name and description to make it truly yours.
Expand All @@ -23,7 +25,12 @@ It will convert existing databases and afterwards remove the .yap file.
* [Jesse Belanger] Added Charm descriptions for Infernals. Most texts taken from the official Wiki.
* [Curtis Tasker] The character sheet adds the highest Dodge specialty to the Dodge DV
* [Curtis Tasker] The character sheet adds the highest Awareness specialty to Join Battle
* [Curtis Tasker] Improved behaviour of tabs
* [Curtis Tasker] Improved behavior of tabs
* [Curtis Tasker] Improved look of toolbar buttons
* [Curtis Tasker] Added basic weapons, armor, and shields from the Errata into the equipment database.
* [Curtis Tasker] Added a 'copy item' button to the equipment database.
* [Curtis Tasker] Added tooltips to the buttons in the equipment database.
* [Curtis Tasker] Improved confirmation dialog for item deletion in the equipment database.
* We now import custom charms from your repository, if the data files are provided. Consult the provided
"Custom Charms.txt" for basic instructions.

Expand Down
Expand Up @@ -26,6 +26,10 @@ public Icon getSaveIcon() {
public Icon getNewIcon() {
return getIcon("ButtonNew16.png"); //$NON-NLS-1$
}

public Icon getCopyIcon() {
return getIcon("ButtonDuplicate16.png"); //$NON-NLS-1$
}

public Icon getSaveAllTaskBarIcon() {
return getIcon("TaskBarSaveAll24.png"); //$NON-NLS-1$
Expand Down
Expand Up @@ -34,7 +34,7 @@ private void configureActionIcons(Action action) {

Image image = new BufferedImage(width, height, Transparency.TRANSLUCENT);
Graphics2D graphics = (Graphics2D) image.getGraphics();
Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f);
Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .8f);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the toolbar so much more readable. I got really tired of mousing over toolbar icons to be able to figure out what's greyed out and what's actually usable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, the more brilliant look helps a long way.

graphics.setComposite(alpha);
graphics.drawImage(rolloverIcon.getImage(), 0, 0, null);
graphics.dispose();
Expand Down