Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Commit

Permalink
Added option to hide trees, plants, houses and fences (CTRL+V)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdew committed Sep 17, 2015
1 parent bc250ca commit 6f15a8f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Option to always show the long tooltip on items
* Option to show plant and tree growth stages
* Option to show damage on objects
* Option to selectively hide trees, plants, fences and houses
* Option to hide flavour objects - reduces CPU utilization (taken from romovs client)
* Daylight mode - Ctrl+N to toggle (taken from k-t client)
* Grid overlay (somewhat based on k-t client)
Expand All @@ -21,6 +22,7 @@
* CTRL + W - World tooltip toggle
* CTRL + F - Follow mouse
* CTRL + G - Grid overlay
* CTRL + V - View filter
* CTRL + ALT + Left Click - Drop identical items
* CTRL + Right Click - Transfer identical items between inventory and container

Expand Down
4 changes: 4 additions & 0 deletions src/haven/GameUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class GameUI extends ConsoleHost implements Console.Directory {
public Polity polity;
public HelpWnd help;
public OptWnd opts;
public final ViewFilter viewfilter;
public Collection<DraggedItem> hand = new LinkedList<DraggedItem>();
private WItem vhand;
public ChatUI chat;
Expand Down Expand Up @@ -145,6 +146,9 @@ public boolean mousedown(Coord c, int button) {
opts.hide();
zerg = add(new Zergwnd(), 187, 50);
zerg.hide();
viewfilter = add (new ViewFilter());
viewfilter.c = new Coord(5, portrait.c.add(portrait.sz).y + 10);
viewfilter.hide();
}

private void mapbuttons() {
Expand Down
3 changes: 2 additions & 1 deletion src/haven/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ public void draw(GOut g) {}
public boolean setup(RenderList rl) {
synchronized(glob.oc) {
for(Gob gob : glob.oc)
addgob(rl, gob);
if (ViewFilter.shouldShowGob(gob))
addgob(rl, gob);
}
return(false);
}
Expand Down
2 changes: 2 additions & 0 deletions src/haven/RootWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public boolean globtype(char key, KeyEvent ev) {
} else if(ev.isControlDown() && ev.getKeyCode() == KeyEvent.VK_F) {
ui.gui.map.startMouseFollow(true);
ui.message("Mouse follow mode ENABLED - click to disable", Color.white);
} else if(ev.isControlDown() && ev.getKeyCode() == KeyEvent.VK_V) {
ui.gui.viewfilter.show(!ui.gui.viewfilter.visible);
} else if(key != 0) {
wdgmsg("gk", (int)key);
}
Expand Down
52 changes: 52 additions & 0 deletions src/haven/ViewFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package haven;

public class ViewFilter extends Window {
public static ConfigSettingBoolean trees = new ConfigSettingBoolean("filter-tress", "Trees", true);
public static ConfigSettingBoolean plants = new ConfigSettingBoolean("filter-plants", "Plants", true);
public static ConfigSettingBoolean fences = new ConfigSettingBoolean("filter-fences", "Fences", true);
public static ConfigSettingBoolean houses = new ConfigSettingBoolean("filter-houses", "Houses", true);

public ViewFilter() {
super(Coord.z, "View", true);
int y = 0;

add(trees.makeCheckBox(), new Coord(0, y));

y += 25;
add(plants.makeCheckBox(), new Coord(0, y));

y += 25;
add(fences.makeCheckBox(), new Coord(0, y));

y += 25;
add(houses.makeCheckBox(), new Coord(0, y));

pack();
}

@SuppressWarnings("SimplifiableIfStatement")
public static boolean shouldShowGob(Gob gob) {
Resource res = gob.getres();
if (res == null) return true;

if (res.name.startsWith("gfx/terobjs/trees/"))
return trees.isEnabled();

if (res.name.startsWith("gfx/terobjs/plants/"))
return plants.isEnabled();

if (res.name.startsWith("gfx/terobjs/arch/palisade") || res.name.startsWith("gfx/terobjs/arch/pole"))
return fences.isEnabled();

if (res.name.startsWith("gfx/terobjs/arch/logcabin")
|| res.name.startsWith("gfx/terobjs/arch/stonemansion")
|| res.name.startsWith("gfx/terobjs/arch/timberhouse")
|| res.name.startsWith("gfx/terobjs/arch/logcabin")
|| res.name.startsWith("gfx/terobjs/arch/stonestead")
)
return houses.isEnabled();


return true;
}
}

0 comments on commit 6f15a8f

Please sign in to comment.