-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
653 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,78 @@ | ||
package commands; | ||
|
||
import gui.ListItem; | ||
import gui.MetaInfos; | ||
import listeners.ItemGuiListener; | ||
import util.Log; | ||
import worldData.HasInfosInterface; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* TODO name this Command ? | ||
* | ||
* @author Spobo | ||
* | ||
*/ | ||
public abstract class Command implements ListItem, HasInfosInterface { | ||
|
||
private MetaInfos myInfoObj; | ||
private ItemGuiListener myItemGuiListener; | ||
|
||
/** | ||
* @param transfairObject | ||
* @return true if command was successful. if the transfairObject isn't used | ||
* the default execute()-method will be executed | ||
*/ | ||
public boolean execute(Object transfairObject) { | ||
/* | ||
* on default the transfairObject isnt used, this way only command which | ||
* need the transfairobject will have to override this method | ||
*/ | ||
return execute(); | ||
} | ||
|
||
public abstract boolean execute(); | ||
|
||
@Override | ||
public View getMyListItemView(View viewToUseIfNotNull, ViewGroup parentView) { | ||
if (myItemGuiListener != null) | ||
return myItemGuiListener.requestItemView(viewToUseIfNotNull, | ||
parentView); | ||
Log.d("GUI", " -> Loading default view for " + this.getClass()); | ||
return getInfoObject().getDefaultListItemView(viewToUseIfNotNull, | ||
parentView); | ||
} | ||
|
||
/** | ||
* TODO remove or refactor, this is never used | ||
* | ||
* @param myItemGuiListener | ||
*/ | ||
public void setMyItemGuiListener(ItemGuiListener myItemGuiListener) { | ||
this.myItemGuiListener = myItemGuiListener; | ||
} | ||
|
||
@Override | ||
public Command getListClickCommand() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public Command getListLongClickCommand() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public MetaInfos getInfoObject() { | ||
if (myInfoObj == null) | ||
myInfoObj = new MetaInfos(this); | ||
return myInfoObj; | ||
} | ||
|
||
@Override | ||
public boolean HasInfoObject() { | ||
if (myInfoObj != null) | ||
return true; | ||
return false; | ||
} | ||
|
||
package commands; | ||
|
||
import gui.ListItem; | ||
import gui.MetaInfos; | ||
import listeners.ItemGuiListener; | ||
import util.Log; | ||
import worldData.HasInfosInterface; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
/** | ||
* TODO name this Command ? | ||
* | ||
* @author Spobo | ||
* | ||
*/ | ||
public abstract class Command implements ListItem, HasInfosInterface { | ||
|
||
private MetaInfos myInfoObj; | ||
private ItemGuiListener myItemGuiListener; | ||
|
||
/** | ||
* @param transfairObject | ||
* @return true if command was successful. if the transfairObject isn't used | ||
* the default execute()-method will be executed | ||
*/ | ||
public boolean execute(Object transfairObject) { | ||
/* | ||
* on default the transfairObject isnt used, this way only command which | ||
* need the transfairobject will have to override this method | ||
*/ | ||
return execute(); | ||
} | ||
|
||
public abstract boolean execute(); | ||
|
||
@Override | ||
public View getMyListItemView(View viewToUseIfNotNull, ViewGroup parentView) { | ||
if (myItemGuiListener != null) | ||
return myItemGuiListener.requestItemView(viewToUseIfNotNull, | ||
parentView); | ||
Log.d("GUI", " -> Loading default view for " + this.getClass()); | ||
return getInfoObject().getDefaultListItemView(viewToUseIfNotNull, | ||
parentView); | ||
} | ||
|
||
/** | ||
* TODO remove or refactor, this is never used | ||
* | ||
* @param myItemGuiListener | ||
*/ | ||
public void setMyItemGuiListener(ItemGuiListener myItemGuiListener) { | ||
this.myItemGuiListener = myItemGuiListener; | ||
} | ||
|
||
@Override | ||
public Command getListClickCommand() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public Command getListLongClickCommand() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public MetaInfos getInfoObject() { | ||
if (myInfoObj == null) | ||
myInfoObj = new MetaInfos(this); | ||
return myInfoObj; | ||
} | ||
|
||
@Override | ||
public boolean HasInfoObject() { | ||
return myInfoObj != null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,45 @@ | ||
package components; | ||
|
||
import commands.Command; | ||
|
||
import worldData.Entity; | ||
import worldData.UpdateTimer; | ||
import worldData.Updateable; | ||
import worldData.Visitor; | ||
|
||
public class TimerComp implements Entity { | ||
|
||
private UpdateTimer timer; | ||
private Updateable myParent; | ||
|
||
public TimerComp(float countdownTimeInSeconds, Command commandToExecute) { | ||
timer = new UpdateTimer(countdownTimeInSeconds, commandToExecute); | ||
} | ||
|
||
@Override | ||
public boolean update(float timeDelta, Updateable parent) { | ||
setMyParent(parent); | ||
if (timer.update(timeDelta, this)) { | ||
/* | ||
* if the timer returns true that means its time was up and it was | ||
* executed correctly so the TImerComp can be removed from its | ||
* parent -> return false | ||
*/ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean accept(Visitor visitor) { | ||
return visitor.visit(this); | ||
} | ||
|
||
@Override | ||
public Updateable getMyParent() { | ||
return myParent; | ||
} | ||
|
||
@Override | ||
public void setMyParent(Updateable parent) { | ||
myParent = parent; | ||
} | ||
|
||
} | ||
package components; | ||
|
||
import commands.Command; | ||
|
||
import worldData.Entity; | ||
import worldData.UpdateTimer; | ||
import worldData.Updateable; | ||
import worldData.Visitor; | ||
|
||
public class TimerComp implements Entity { | ||
|
||
private UpdateTimer timer; | ||
private Updateable myParent; | ||
|
||
public TimerComp(float countdownTimeInSeconds, Command commandToExecute) { | ||
timer = new UpdateTimer(countdownTimeInSeconds, commandToExecute); | ||
} | ||
|
||
@Override | ||
public boolean update(float timeDelta, Updateable parent) { | ||
setMyParent(parent); | ||
/* | ||
* if the timer returns true that means its time was up and it was | ||
* executed correctly so the TImerComp can be removed from its | ||
* parent -> return false | ||
*/ | ||
return !timer.update(timeDelta, this); | ||
} | ||
|
||
@Override | ||
public boolean accept(Visitor visitor) { | ||
return visitor.visit(this); | ||
} | ||
|
||
@Override | ||
public Updateable getMyParent() { | ||
return myParent; | ||
} | ||
|
||
@Override | ||
public void setMyParent(Updateable parent) { | ||
myParent = parent; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.