mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Bazaar resizing fixed.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -11147,6 +11147,7 @@ src/main/java/forge/card/trigger/TriggerTurnFaceUp.java svneol=native#text/plain
|
|||||||
src/main/java/forge/card/trigger/TriggerUnequip.java svneol=native#text/plain
|
src/main/java/forge/card/trigger/TriggerUnequip.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/trigger/TriggerUntaps.java svneol=native#text/plain
|
src/main/java/forge/card/trigger/TriggerUntaps.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/trigger/package-info.java svneol=native#text/plain
|
src/main/java/forge/card/trigger/package-info.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/control/ControlBazaarUI.java -text
|
||||||
src/main/java/forge/control/ControlHomeUI.java -text
|
src/main/java/forge/control/ControlHomeUI.java -text
|
||||||
src/main/java/forge/control/ControlMatchUI.java -text
|
src/main/java/forge/control/ControlMatchUI.java -text
|
||||||
src/main/java/forge/control/FControl.java -text
|
src/main/java/forge/control/FControl.java -text
|
||||||
|
|||||||
60
src/main/java/forge/control/ControlBazaarUI.java
Normal file
60
src/main/java/forge/control/ControlBazaarUI.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package forge.control;
|
||||||
|
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.awt.event.ComponentListener;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
import forge.view.ViewBazaarUI;
|
||||||
|
import forge.view.toolbox.FLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ControlBazaarUI {
|
||||||
|
private final ViewBazaarUI view;
|
||||||
|
private final ComponentListener cadResize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls top-level instance of bazaar.
|
||||||
|
* @param v0   {@link forge.view.ViewBazaarUI}
|
||||||
|
*/
|
||||||
|
public ControlBazaarUI(ViewBazaarUI v0) {
|
||||||
|
view = v0;
|
||||||
|
|
||||||
|
cadResize = new ComponentAdapter() {
|
||||||
|
@Override
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
view.revalidate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
addListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addListeners() {
|
||||||
|
this.view.removeComponentListener(cadResize);
|
||||||
|
this.view.addComponentListener(cadResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Populate all stalls, and select first one. */
|
||||||
|
public void initBazaar() {
|
||||||
|
view.populateStalls();
|
||||||
|
((FLabel) view.getPnlAllStalls().getComponent(0)).setSelected(true);
|
||||||
|
showStall(QuestStallManager.getStallNames().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @param s0   {@link java.lang.String} */
|
||||||
|
public void showStall(final String s0) {
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
view.getPnlSingleStall().setStall(QuestStallManager.getStall(s0));
|
||||||
|
view.getPnlSingleStall().updateStall();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import javax.swing.SwingUtilities;
|
|||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
|
import forge.control.ControlBazaarUI;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
import forge.view.bazaar.ViewStall;
|
import forge.view.bazaar.ViewStall;
|
||||||
import forge.view.toolbox.FLabel;
|
import forge.view.toolbox.FLabel;
|
||||||
@@ -19,6 +20,7 @@ import forge.view.toolbox.FSkin;
|
|||||||
public class ViewBazaarUI extends FPanel {
|
public class ViewBazaarUI extends FPanel {
|
||||||
private final JPanel pnlAllStalls;
|
private final JPanel pnlAllStalls;
|
||||||
private final ViewStall pnlSingleStall;
|
private final ViewStall pnlSingleStall;
|
||||||
|
private final ControlBazaarUI control;
|
||||||
private FLabel previousSelected;
|
private FLabel previousSelected;
|
||||||
|
|
||||||
/** Lays out containers and borders for resizeable layout and
|
/** Lays out containers and borders for resizeable layout and
|
||||||
@@ -42,14 +44,14 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
this.add(pnlAllStalls, "w 25%!, h 100%!");
|
this.add(pnlAllStalls, "w 25%!, h 100%!");
|
||||||
this.add(pnlSingleStall, "w 75%!, h 100%!");
|
this.add(pnlSingleStall, "w 75%!, h 100%!");
|
||||||
|
|
||||||
// Populate all stalls, and select first one.
|
// Instantiate control
|
||||||
populateStalls();
|
control = new ControlBazaarUI(this);
|
||||||
((FLabel) pnlAllStalls.getComponent(0)).setSelected(true);
|
control.initBazaar();
|
||||||
previousSelected = ((FLabel) pnlAllStalls.getComponent(0));
|
previousSelected = ((FLabel) pnlAllStalls.getComponent(0));
|
||||||
showStall(QuestStallManager.getStallNames().get(0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateStalls() {
|
/** */
|
||||||
|
public void populateStalls() {
|
||||||
for (final String s : QuestStallManager.getStallNames()) {
|
for (final String s : QuestStallManager.getStallNames()) {
|
||||||
final FLabel lbl = new FLabel.Builder().text(s + " ")
|
final FLabel lbl = new FLabel.Builder().text(s + " ")
|
||||||
.fontAlign(SwingConstants.RIGHT).iconInBackground(true)
|
.fontAlign(SwingConstants.RIGHT).iconInBackground(true)
|
||||||
@@ -63,22 +65,12 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
if (previousSelected != null) { previousSelected.setSelected(false); }
|
if (previousSelected != null) { previousSelected.setSelected(false); }
|
||||||
previousSelected = lbl;
|
previousSelected = lbl;
|
||||||
showStall(s);
|
control.showStall(s);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showStall(final String s0) {
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
pnlSingleStall.setStall(QuestStallManager.getStall(s0));
|
|
||||||
pnlSingleStall.updateStall();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public void refreshLastInstance() {
|
public void refreshLastInstance() {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@@ -88,4 +80,20 @@ public class ViewBazaarUI extends FPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return {@link javax.swing.JPanel}
|
||||||
|
*/
|
||||||
|
public JPanel getPnlAllStalls() {
|
||||||
|
return this.pnlAllStalls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return {@link forge.view.bazaar.ViewStall}
|
||||||
|
*/
|
||||||
|
public ViewStall getPnlSingleStall() {
|
||||||
|
return this.pnlSingleStall;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user