Skip to content

Commit

Permalink
Merge pull request #6687 from kevlahnota/master2
Browse files Browse the repository at this point in the history
clear bookmarks
  • Loading branch information
kevlahnota authored Dec 14, 2024
2 parents 19023a9 + 63bf2b1 commit 01e1a8f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 30 deletions.
4 changes: 4 additions & 0 deletions forge-gui-mobile/src/forge/adventure/scene/MapViewScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,8 @@ float getMapY(float posY) {
return (posY / (float) WorldSave.getCurrentSave().getWorld().getTileSize() / (float) WorldSave.getCurrentSave().getWorld().getHeightInTiles()) * img.getHeight();
}

public void clearBookMarks() {
if (bookmark != null)
bookmark.clear();
}
}
2 changes: 2 additions & 0 deletions forge-gui-mobile/src/forge/adventure/scene/SaveLoadScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void loadSave() {
break;
case Load:
try {
MapViewScene.instance().clearBookMarks();
Forge.setTransitionScreen(new TransitionScreen(() -> {
loaded = false;
if (WorldSave.load(currentSlot)) {
Expand Down Expand Up @@ -253,6 +254,7 @@ public void loadSave() {
Current.player().resetQuestFlags();
Current.player().setCharacterFlag("newGamePlus", 1);
AdventurePlayer.current().addQuest("28");
WorldSave.getCurrentSave().clearBookmarks();
WorldStage.getInstance().enterSpawnPOI();
SoundSystem.instance.changeBackgroundTrack();
Forge.switchScene(GameScene.instance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ public void initialize() {
}

public ColorMap sourceImage() {
return new ColorMap(Config.instance().getFile(data.sourcePath));
return new ColorMap(Config.instance().getFile(data.sourcePath), data.sourcePath);
}

public String sourceImagePath() {
return (Config.instance().getFilePath(data.sourcePath));
}

private ColorMap maskImage() {
return new ColorMap(Config.instance().getFile(data.maskPath));

return new ColorMap(Config.instance().getFile(data.maskPath), data.maskPath);
}


Expand Down
54 changes: 27 additions & 27 deletions forge-gui-mobile/src/forge/adventure/world/ColorMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,53 @@
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;

public class ColorMap
{
public class ColorMap {
private final int width;
private final int height;
private final Color[] data;
public ColorMap(int w,int h)
{
width=w;
height=h;
data=new Color[w*h];
for(int i=0;i<w*h;i++)
data[i]=new Color();

public ColorMap(int w, int h) {
width = w;
height = h;
data = new Color[w * h];
for (int i = 0; i < w * h; i++)
data[i] = new Color();
}

public ColorMap(FileHandle file) {
if (file.exists()) {
Pixmap pdata=new Pixmap(file);
width=pdata.getWidth();
height=pdata.getHeight();
data=new Color[width*height];
for(int y=0;y<height;y++)
for(int x=0;x<width;x++)
{
data[x+y*width]=new Color(pdata.getPixel(x,y));
public ColorMap(FileHandle file, String path) {
if (file != null && file.exists()) {
Pixmap pdata = new Pixmap(file);
width = pdata.getWidth();
height = pdata.getHeight();
data = new Color[width * height];
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++) {
data[x + y * width] = new Color(pdata.getPixel(x, y));
}
pdata.dispose();
} else {
width = 0;
height = 0;
data = new Color[0];
System.err.println("Cannot find file for ColorMap: " + file.path());
width = 1;
height = 1;
data = new Color[1];
for (int i = 0; i < width * height; i++)
data[i] = new Color();
System.err.println("Cannot find file for ColorMap: " + path);
}
}

public int getWidth() {
return width;
}
public int getHeight()
{

public int getHeight() {
return height;
}

public Color getColor(int x, int y) {
return data[x+y*width];
return data[x + y * width];
}

public void setColor(int x, int y, Color c) {
data[x+y*width].set(c);
data[x + y * width].set(c);
}
}
19 changes: 19 additions & 0 deletions forge-gui-mobile/src/forge/adventure/world/WorldSave.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

import forge.adventure.data.DifficultyData;
import forge.adventure.player.AdventurePlayer;
import forge.adventure.pointofintrest.PointOfInterest;
import forge.adventure.pointofintrest.PointOfInterestChanges;
import forge.adventure.scene.MapViewScene;
import forge.adventure.scene.SaveLoadScene;
import forge.adventure.stage.PointOfInterestMapSprite;
import forge.adventure.stage.WorldStage;
import forge.adventure.util.AdventureModes;
import forge.adventure.util.Config;
Expand Down Expand Up @@ -183,4 +186,20 @@ public void clearChanges() {
pointOfInterestChanges.clear();
}

public void clearBookmarks() {
for (PointOfInterest poi : currentSave.world.getAllPointOfInterest()) {
if (poi == null)
continue;
PointOfInterestMapSprite mapSprite = WorldStage.getInstance().getMapSprite(poi);
if (mapSprite != null)
mapSprite.setBookmarked(false, poi);
PointOfInterestChanges p = pointOfInterestChanges.get(poi.getID());
if (p == null)
continue;
p.setIsBookmarked(false);
p.save();
}
MapViewScene.instance().clearBookMarks();
}

}

0 comments on commit 01e1a8f

Please sign in to comment.