Skip to content

Commit

Permalink
Massive redesign of the colony panel with background images and other…
Browse files Browse the repository at this point in the history
… styling. Buildings are now randomly distributed in the colony based on the available space (this is annoying when resizing the colony panel, but otherwise really good). The sizes of various panels have been tweaked to work both on small and large displays ... and panels that previously often required scrollbars have now been repositioned and made bigger.
  • Loading branch information
stiangre committed Jan 1, 2024
1 parent 1fc5957 commit 19f7113
Show file tree
Hide file tree
Showing 8 changed files with 820 additions and 106 deletions.
70 changes: 70 additions & 0 deletions data/base/resources.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ image.background.FreeColButton=resources/images/ui/bg_button.png
image.background.MainPanel=resources/images/ui/bg_brown.png
image.background.AboutPanel=resources/images/ui/bg_brown.png
image.background.ColopediaPanel=resources/images/ui/bg_brown.png
image.background.ColonyPanel=resources/images/ui/bg_paper_brown.png

image.background.FreeColList=resource:image.background.Paper
image.background.FreeColMenuBar=resources/images/ui/bg_menubar.png
Expand All @@ -48,6 +49,13 @@ image.background.FreeColTextArea=resource:image.background.FreeColBrightPanel
image.background.FreeColTextField=resource:image.background.FreeColBrightPanel
image.background.FreeColToolTip=resource:image.background.Paper

image.cargohold.available=resources/images/ui/cargohold.png
image.cargohold.unavailable=resources/images/ui/cargohold-unavailable.png
image.colony.docks.background=resources/images/ui/colonydocks.png
image.colony.docks.sky.background=resources/images/ui/colonydocks-sky.png
image.colony.warehouse.background=resources/images/ui/warehouse-bg.png
image.colony.upperRight.background=resources/images/ui/colony-upper-right-bg.png

# Borders
#image.border.menu.s=resource:image.empty
image.border.menu.s=resources/images/ui/menuborder.png
Expand Down Expand Up @@ -88,6 +96,68 @@ image.border.button.simple.ne=resources/images/ui/simplebuttonborder-ne.png
image.border.button.simple.sw=resources/images/ui/simplebuttonborder-sw.png
image.border.button.simple.se=resources/images/ui/simplebuttonborder-se.png

image.border.wooden.n=resources/images/ui/border/wooden/woodenborder-n.png
image.border.wooden.w=resources/images/ui/border/wooden/woodenborder-w.png
image.border.wooden.e=resources/images/ui/border/wooden/woodenborder-e.png
image.border.wooden.s=resources/images/ui/border/wooden/woodenborder-s.png
image.border.wooden.nw=resources/images/ui/border/wooden/woodenborder-nw.png
image.border.wooden.ne=resources/images/ui/border/wooden/woodenborder-ne.png
image.border.wooden.sw=resources/images/ui/border/wooden/woodenborder-sw.png
image.border.wooden.se=resources/images/ui/border/wooden/woodenborder-se.png

image.border.colonyWarehouse.n=resources/images/ui/border/wooden/woodenborder-n.png
#image.border.colonyWarehouse.w=resources/images/ui/border/wooden/woodenborder-w.png
image.border.colonyWarehouse.e=resources/images/ui/border/wooden/woodenborder-e.png
#image.border.colonyWarehouse.s=resources/images/ui/border/wooden/woodenborder-s.png
image.border.colonyWarehouse.nw=resources/images/ui/border/wooden/woodenborder-nw.png
image.border.colonyWarehouse.ne=resources/images/ui/border/wooden/woodenborder-ne.png
#image.border.colonyWarehouse.sw=resources/images/ui/border/wooden/woodenborder-sw.png
#image.border.colonyWarehouse.se=resources/images/ui/border/wooden/woodenborder-se.png

image.border.colony.panel.n=resources/images/ui/border/carvedwood/carvedwoodenborder-n.png
image.border.colony.panel.w=resources/images/ui/border/carvedwood/carvedwoodenborder-w.png
image.border.colony.panel.e=resources/images/ui/border/carvedwood/carvedwoodenborder-e.png
image.border.colony.panel.s=resources/images/ui/border/carvedwood/carvedwoodenborder-s.png
image.border.colony.panel.nw=resources/images/ui/border/carvedwood/carvedwoodenborder-nw.png
image.border.colony.panel.ne=resources/images/ui/border/carvedwood/carvedwoodenborder-ne.png
image.border.colony.panel.sw=resources/images/ui/border/carvedwood/carvedwoodenborder-sw.png
image.border.colony.panel.se=resources/images/ui/border/carvedwood/carvedwoodenborder-se.png

image.border.colony.panel.inner.n=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-n.png
image.border.colony.panel.inner.w=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-w.png
image.border.colony.panel.inner.e=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-e.png
image.border.colony.panel.inner.s=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-s.png
image.border.colony.panel.inner.nw=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-nw.png
#image.border.colony.panel.inner.ne=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-ne.png
image.border.colony.panel.inner.sw=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-sw.png
image.border.colony.panel.inner.se=resources/images/ui/border/carvedwood/carvedwoodenborder-inner-se.png

image.border.colony.panel.inner.ne=resources/images/ui/border/carvedwood/carvedwood-colony-inner-ne.png
image.border.colony.panel.inner.nne=resources/images/ui/border/carvedwood/carvedwood-colony-inner-nne.png
image.border.colony.panel.inner.ene=resources/images/ui/border/carvedwood/carvedwood-colony-inner-ene.png


image.border.colony.panel.outer.n=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-n.png
image.border.colony.panel.outer.w=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-w.png
image.border.colony.panel.outer.e=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-e.png
image.border.colony.panel.outer.s=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-s.png
image.border.colony.panel.outer.nw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-nw.png
#image.border.colony.panel.outer.ne=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-ne.png
image.border.colony.panel.outer.sw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-sw.png
image.border.colony.panel.outer.se=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-se.png
image.border.colony.panel.outer.nnw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-nnw.png
#image.border.colony.panel.outer.nne=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-nne.png
#image.border.colony.panel.outer.ene=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-ene.png
image.border.colony.panel.outer.ese=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-ese.png
image.border.colony.panel.outer.sse=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-sse.png
image.border.colony.panel.outer.ssw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-ssw.png
image.border.colony.panel.outer.wsw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-wsw.png
image.border.colony.panel.outer.wnw=resources/images/ui/border/carvedwood/carvedwoodenborder-outer-wnw.png
image.border.colony.panel.outer.ne=resources/images/ui/border/carvedwood/carvedwood-colony-outer-ne.png
image.border.colony.panel.outer.nne=resources/images/ui/border/carvedwood/carvedwood-colony-outer-nne.png
image.border.colony.panel.outer.ene=resources/images/ui/border/carvedwood/carvedwood-colony-outer-ene.png


# Interface
image.ui.button.radio=resources/images/ui/button-radio.png
image.ui.button.radio.selected=resources/images/ui/button-radio-selected.png
Expand Down
50 changes: 50 additions & 0 deletions src/net/sf/freecol/client/gui/ImageLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,36 @@ public BufferedImage getScaledBuildingTypeImage(BuildingType buildingType,
final String key = getBuildingTypeKey(buildingType);
return this.imageCache.getScaledImage(key, scale, false);
}

public BufferedImage getScaledCargoHold(boolean available) {
final String key = "image.cargohold." + (available ? "available" : "unavailable");
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

public BufferedImage getColonyDocks() {
final String key = "image.colony.docks.background";
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

public BufferedImage getColonyDocksSky() {
final String key = "image.colony.docks.sky.background";
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

public BufferedImage getColonyUpperRightBackground() {
final String key = "image.colony.upperRight.background";
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

public BufferedImage getColonyWarehouseBackground() {
final String key = "image.colony.warehouse.background";
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

public BufferedImage getScaledBuildingEmptyLandImage() {
final String key = "image.buildingicon.model.building.BuildingSite";
return this.imageCache.getScaledImage(key, this.scaleFactor, false);
}

private BufferedImage getScaledBuildingTypeImage(BuildingType buildingType,
Player player,
Expand All @@ -832,6 +862,26 @@ private BufferedImage getScaledBuildingTypeImage(BuildingType buildingType,
}
return this.imageCache.getScaledImage(key, scale, false);
}

public Dimension determineMaxSizeUsingSizeFromAllLevels(BuildingType buildingType, Player player) {
int maxWidth = 0;
int maxHeight = 0;
while (buildingType.getUpgradesFrom() != null) {
buildingType = buildingType.getUpgradesFrom();
}
do {
final Image buildingImage = getScaledBuildingTypeImage(buildingType, player, getScaleFactor());
if (buildingImage.getWidth(null) > maxWidth) {
maxWidth = buildingImage.getWidth(null);
}
if (buildingImage.getHeight(null) > maxHeight) {
maxHeight = buildingImage.getHeight(null);
}
buildingType = buildingType.getUpgradesTo();
} while (buildingType != null);

return new Dimension(maxWidth, maxHeight);
}

public BufferedImage getScaledBuildingImage(Building building) {
return getScaledBuildingTypeImage(building.getType(),
Expand Down
22 changes: 14 additions & 8 deletions src/net/sf/freecol/client/gui/panel/BuildingPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.sf.freecol.common.model.Ability;
import net.sf.freecol.common.model.AbstractGoods;
import net.sf.freecol.common.model.Building;
import net.sf.freecol.common.model.BuildingType;
import net.sf.freecol.common.model.Colony;
import net.sf.freecol.common.model.ProductionInfo;
import net.sf.freecol.common.model.Unit;
Expand Down Expand Up @@ -189,16 +190,16 @@ protected void update() {
unitLabels.add(unitLabel);
add(unitLabel);
}

ImageLibrary lib = getImageLibrary();
Image buildingImage = lib.getScaledBuildingImage(building);
setPreferredSize(new Dimension(buildingImage.getWidth(null),
buildingImage.getHeight(null)));

final BufferedImage image = getImageLibrary().getScaledBuildingImage(building);
setMinimumSize(new Dimension(image.getWidth(), image.getHeight()));

final Dimension preferredSize = getImageLibrary().determineMaxSizeUsingSizeFromAllLevels(building.getType(), building.getOwner());
setPreferredSize(preferredSize);
revalidate();
repaint();
}


/**
* Get the building this panel displays.
*
Expand Down Expand Up @@ -252,8 +253,13 @@ public JToolTip createToolTip() {
*/
@Override
public void paintComponent(Graphics g) {
ImageLibrary lib = getImageLibrary();
g.drawImage(lib.getScaledBuildingImage(building), 0, 0, this);
final ImageLibrary lib = getImageLibrary();
final BufferedImage image = lib.getScaledBuildingImage(building);
final Dimension size = getSize();
g.drawImage(image,
(size.width - image.getWidth()) / 2,
size.height - image.getHeight(),
this);
}


Expand Down
Loading

0 comments on commit 19f7113

Please sign in to comment.