Improve caption slightly more

This commit is contained in:
drdev
2014-04-12 04:56:48 +00:00
parent 5085b85331
commit 4afab1c6d1
3 changed files with 18 additions and 15 deletions

View File

@@ -303,8 +303,6 @@ public class FDeckChooser extends FScreen {
}
if (deckType == null) { return; }
lstDecks.setCaption(deckType.toString());
switch (deckType) {
case CUSTOM_DECK:
updateCustom();

View File

@@ -40,35 +40,37 @@ public final class DeckManager extends ItemManager<DeckProxy> {
*/
public DeckManager(final GameType gt) {
super(DeckProxy.class, true);
this.gametype = gt;
gametype = gt;
this.setItemActivateHandler(new FEventHandler() {
setItemActivateHandler(new FEventHandler() {
@Override
public void handleEvent(FEvent e) {
editDeck(getSelectedItem());
}
});
setCaption("Decks");
}
@Override
public void setup(ItemManagerConfig config0) {
boolean wasStringOnly = (this.getConfig() == ItemManagerConfig.STRING_ONLY);
boolean wasStringOnly = (getConfig() == ItemManagerConfig.STRING_ONLY);
boolean isStringOnly = (config0 == ItemManagerConfig.STRING_ONLY);
super.setup(config0, null);
if (isStringOnly != wasStringOnly) {
this.restoreDefaultFilters();
restoreDefaultFilters();
}
}
public void setDeleteCommand(final FEventHandler c0) {
this.cmdDelete = c0;
cmdDelete = c0;
}
@Override
protected void addDefaultFilters() {
if (this.getConfig() == ItemManagerConfig.STRING_ONLY) { return; }
if (getConfig() == ItemManagerConfig.STRING_ONLY) { return; }
addFilter(new DeckColorFilter(this));
}
@@ -164,7 +166,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
/*FScreen screen = null;
switch (this.gametype) {
switch (gametype) {
case Quest:
screen = FScreen.DECK_EDITOR_QUEST;
editorCtrl = new CEditorQuest(FModel.getQuest());
@@ -208,7 +210,7 @@ public final class DeckManager extends ItemManager<DeckProxy> {
}
// consider using deck proxy's method to delete deck
switch(this.gametype) {
switch(gametype) {
case Constructed:
case Draft:
case Sealed:
@@ -222,10 +224,10 @@ public final class DeckManager extends ItemManager<DeckProxy> {
throw new UnsupportedOperationException("Delete not implemneted for game type = " + gametype.toString());
}
this.removeItem(deck, 1);
removeItem(deck, 1);
if (this.cmdDelete != null) {
this.cmdDelete.handleEvent(new FEvent(this, FEventType.DELETE));
if (cmdDelete != null) {
cmdDelete.handleEvent(new FEvent(this, FEventType.DELETE));
}
return true;
}

View File

@@ -283,12 +283,15 @@ public abstract class ItemManager<T extends InventoryItem> extends FContainer im
float ratioWidth = lblRatio.getAutoSizeBounds().width;
float viewButtonWidth = fieldHeight;
float viewButtonCount = views.size() + 1;
float availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 2) * helper.getGapX();
float availableCaptionWidth = helper.getParentWidth() - viewButtonWidth * viewButtonCount - ratioWidth - helper.getX() - (viewButtonCount + 1) * helper.getGapX();
if (captionWidth > availableCaptionWidth) { //truncate caption if not enough room for it
captionWidth = availableCaptionWidth;
}
helper.offset(0, 1); //shift caption downward
helper.include(lblCaption, captionWidth, fieldHeight);
helper.offset(-helper.getGapX(), 0);
helper.fillLine(lblRatio, fieldHeight, (viewButtonWidth + helper.getGapX()) * viewButtonCount - viewButtonCount + 1); //leave room for view buttons
helper.offset(0, -1);
for (ItemView<T> view : views) {
helper.include(view.getButton(), viewButtonWidth, fieldHeight);
helper.offset(-1, 0);