mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Allow to addd hint texts to stack abilities. Swicthed to html text format for text box of stack abilites.
This commit is contained in:
parent
f409f56c05
commit
84370ee5ab
11 changed files with 64 additions and 46 deletions
|
|
@ -6,7 +6,7 @@
|
|||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="new Dimension(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT)" type="code"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
<Property name="name" type="java.lang.String" value="bigCardPanel" noResource="true"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection component="Form" name="minimumSize" type="property"/>
|
||||
</Property>
|
||||
|
|
@ -30,11 +30,18 @@
|
|||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="scrollPane">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="dc" green="dc" red="dc" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="horizontalScrollBarPolicy" type="int" value="31"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
<Property name="viewportBorder" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
|
||||
<EtchetBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_allCodePost" type="java.lang.String" value="scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));"/>
|
||||
|
|
@ -42,7 +49,7 @@
|
|||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription">
|
||||
<AbsoluteConstraints x="20" y="230" width="210" height="120"/>
|
||||
<AbsoluteConstraints x="20" y="220" width="210" height="130"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
|
|
@ -50,9 +57,7 @@
|
|||
<SubComponents>
|
||||
<Component class="javax.swing.JTextPane" name="text">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
|
|
@ -15,9 +16,10 @@ import java.awt.Rectangle;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.StyledDocument;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
|
||||
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
|
||||
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
|
||||
|
|
@ -29,6 +31,7 @@ import mage.client.util.ImageHelper;
|
|||
import mage.constants.EnlargeMode;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
import mage.client.util.TransformedImageCache;
|
||||
import org.mage.card.arcane.UI;
|
||||
|
||||
/**
|
||||
* Class for displaying big image of the card
|
||||
|
|
@ -62,6 +65,9 @@ public class BigCard extends JComponent {
|
|||
setOpaque(true);
|
||||
this.scrollPane.setOpaque(true);
|
||||
this.scrollPane.setVisible(false);
|
||||
|
||||
UI.setHTMLEditorKit(text);
|
||||
text.setEditable(false);
|
||||
}
|
||||
|
||||
private void initBounds(boolean rotated) {
|
||||
|
|
@ -69,8 +75,8 @@ public class BigCard extends JComponent {
|
|||
if (rotated) {
|
||||
scrollPane.setBounds(50, 50, 100, 100);
|
||||
} else {
|
||||
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1100,
|
||||
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
|
||||
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1150,
|
||||
this.getWidth()*1000/1130,this.getWidth()*1000/2100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -95,8 +101,14 @@ public class BigCard extends JComponent {
|
|||
synchronized (this) {
|
||||
source = null;
|
||||
hue = 0.000f;
|
||||
}
|
||||
drawText(strings);
|
||||
}
|
||||
StringBuilder displayedText = new StringBuilder();
|
||||
for (String textLine: strings) {
|
||||
if (textLine != null && !textLine.replace(".", "").trim().isEmpty()) {
|
||||
displayedText.append("<p style='margin: 2px'>").append(textLine).append("</p>");
|
||||
}
|
||||
}
|
||||
this.text.setText(displayedText.toString());
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
|
@ -109,19 +121,6 @@ public class BigCard extends JComponent {
|
|||
this.cardId = null;
|
||||
}
|
||||
|
||||
private void drawText(java.util.List<String> strings) {
|
||||
text.setText("");
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
|
||||
try {
|
||||
for (String line : strings) {
|
||||
doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular"));
|
||||
}
|
||||
} catch (BadLocationException ble) {
|
||||
}
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
if (bigImage != null) {
|
||||
|
|
@ -169,21 +168,19 @@ public class BigCard extends JComponent {
|
|||
setFocusable(false);
|
||||
setMinimumSize(new Dimension(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT));
|
||||
setName("bigCardPanel"); // NOI18N
|
||||
setOpaque(false);
|
||||
setPreferredSize(getMinimumSize());
|
||||
setLayout(null);
|
||||
|
||||
scrollPane.setBackground(new java.awt.Color(220, 220, 220));
|
||||
scrollPane.setBorder(null);
|
||||
scrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setOpaque(false);
|
||||
scrollPane.setViewportBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
|
||||
text.setEditable(false);
|
||||
text.setFocusable(false);
|
||||
text.setOpaque(false);
|
||||
scrollPane.setViewportView(text);
|
||||
|
||||
add(scrollPane);
|
||||
scrollPane.setBounds(20, 230, 210, 120);
|
||||
scrollPane.setBounds(20, 220, 210, 130);
|
||||
scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent arg0) {
|
||||
this.bigCard.showTextComponent();
|
||||
// this.bigCard.showTextComponent();
|
||||
this.bigCard.setCard(card.getId(), EnlargeMode.NORMAL, image, getRules(), false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (this.startedDragging && prevCardPanel != null && card != null) {
|
||||
for (Component component : card.getCardArea().getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
if (cardPanels.contains(component)) {
|
||||
if (cardPanels.contains((CardPanel) component)) {
|
||||
component.setLocation(component.getLocation().x, component.getLocation().y - GO_DOWN_ON_DRAG_Y_OFFSET);
|
||||
}
|
||||
}
|
||||
|
|
@ -316,7 +316,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
for (Component component : container.getComponents()) {
|
||||
if (component instanceof CardPanel) {
|
||||
if (!component.equals(card)) {
|
||||
if (!cardPanels.contains(component)) {
|
||||
if (!cardPanels.contains((CardPanel) component)) {
|
||||
component.setLocation(component.getLocation().x, component.getLocation().y + GO_DOWN_ON_DRAG_Y_OFFSET);
|
||||
}
|
||||
cardPanels.add((CardPanel) component);
|
||||
|
|
@ -539,7 +539,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MageComponents mageComponentCardPreviewContainer;
|
||||
MageComponents mageComponentCardPreviewPane;
|
||||
if (cardView.isToRotate()) {
|
||||
|
|
@ -568,7 +568,7 @@ public class MageActionCallback implements ActionCallback {
|
|||
location.translate(-parentPoint.x, -parentPoint.y);
|
||||
popupContainer.setLocation(location);
|
||||
popupContainer.setVisible(true);
|
||||
|
||||
|
||||
MageCard mageCard = (MageCard) transferData.getComponent();
|
||||
Image image = null;
|
||||
switch (enlargeMode) {
|
||||
|
|
@ -593,13 +593,12 @@ public class MageActionCallback implements ActionCallback {
|
|||
image = mageCard.getImage();
|
||||
}
|
||||
// shows the card in the popup Container
|
||||
BigCard bigCard = (BigCard) cardPreviewPane;
|
||||
displayCardInfo(mageCard, image, bigCard);
|
||||
|
||||
displayCardInfo(mageCard, image, (BigCard) cardPreviewPane);
|
||||
|
||||
} else {
|
||||
LOGGER.warn("No Card preview Pane in Mage Frame defined. Card: " + cardView.getName());
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Problem dring display of enlarged card", e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue