Skip to content

Commit

Permalink
added lifemodule exception
Browse files Browse the repository at this point in the history
  • Loading branch information
UrsZeidler committed Mar 29, 2015
1 parent 6abcd0a commit b495626
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import de.urszeidler.eclipse.shr5.util.ShadowrunTools;
import de.urszeidler.eclipse.shr5Management.CharacterGenerator;
import de.urszeidler.eclipse.shr5Management.KarmaGenerator;
import de.urszeidler.eclipse.shr5Management.LifeModulesGenerator;
import de.urszeidler.eclipse.shr5Management.LifeModulesSystem;
import de.urszeidler.eclipse.shr5Management.ManagedCharacter;
import de.urszeidler.eclipse.shr5Management.util.ShadowrunManagmentTools;
import de.urszeidler.shr5.ecp.editor.pages.Messages;
Expand Down Expand Up @@ -191,6 +193,7 @@ public boolean hasChildren(Object element) {
private boolean filterOnlyPersona;
private String stringFilter;
private boolean readOnly = false;
private boolean skillsFixedByGroup = true;

/**
* Create the composite.
Expand Down Expand Up @@ -229,6 +232,9 @@ public PersonaFertigkeitenWidget(Composite parent, int style, ManagedCharacter c
if (chracterSource instanceof KarmaGenerator) {
// Shr5KarmaGenerator skg = (Shr5KarmaGenerator)chracterSource;
karmaMode = true;
if (chracterSource instanceof LifeModulesGenerator) {
skillsFixedByGroup = false;
}
}

createWidgets();
Expand Down Expand Up @@ -406,7 +412,7 @@ protected Object openDialogBox(Control cellEditorWindow) {

@Override
protected boolean canEdit(Object element) {
if(readOnly)
if (readOnly)
return false;
if (element instanceof Fertigkeit) {
Fertigkeit fertigkeit = (Fertigkeit)element;// for #196
Expand Down Expand Up @@ -479,17 +485,18 @@ public String getText(Object element) {
});
treeViewerValueColumn.setEditingSupport(new EditingSupport(treeViewer) {
protected boolean canEdit(Object element) {
if(readOnly)
if (readOnly)
return false;

if (element instanceof GroupWrapper) {
return false;
}// for #196
if (element instanceof Fertigkeit)
if (((Fertigkeit)element).eContainer() instanceof FertigkeitsGruppe) {
FertigkeitsGruppe fg = (FertigkeitsGruppe)((Fertigkeit)element).eContainer();
return ShadowrunTools.findGruppe(fg, persona) == null;
}
}// for #196
if (skillsFixedByGroup)
if (element instanceof Fertigkeit)
if (((Fertigkeit)element).eContainer() instanceof FertigkeitsGruppe) {
FertigkeitsGruppe fg = (FertigkeitsGruppe)((Fertigkeit)element).eContainer();
return ShadowrunTools.findGruppe(fg, persona) == null;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static void changeFertigkeitByAdvacement(ManagedCharacter character, Fert
PersonaChange personaChange = Shr5managementFactory.eINSTANCE.createPersonaChange();
character.getChanges().add(personaChange);
personaChange.setChangeable(pf);
personaChange.setFrom(0);
// personaChange.setFrom(0);
personaChange.setTo((Integer)value);
personaChange.applyChanges();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ public Object caseSteigerbar(Steigerbar object) {
return object;
}

@Override
public Object casePersonaFertigkeit(PersonaFertigkeit object) {
Integer fromValue = object.getStufe();
if(object.getFertigkeit()!=null && getCharacter()!=null && getCharacter().getPersona()!=null)
fromValue = Math.max(object.getStufe() ,ShadowrunTools.findFertigkeitValue(object.getFertigkeit(), getCharacter().getPersona()));
setFrom(fromValue);
setTo(fromValue + 1);
return object;
}

@Override
public Object casePersonaEigenschaft(PersonaEigenschaft object) {
if (ShadowrunManagmentTools.hasEigenschaft(getCharacter(), object)) {
Expand Down Expand Up @@ -243,7 +253,7 @@ public Object casePersonaFertigkeitsGruppe(PersonaFertigkeitsGruppe object) {

@Override
public Object casePersonaFertigkeit(PersonaFertigkeit object) {
if (getFrom() == 0) {
if (ShadowrunTools.findFertigkeit(object.getFertigkeit(), getCharacter().getPersona()) == null) {
getCharacter().getPersona().getFertigkeiten().add(object);
object.setStufe(getTo());
return object;
Expand Down

0 comments on commit b495626

Please sign in to comment.