diff --git a/assets/chrome.png b/assets/chrome.png index e11048efa..d865869a4 100644 Binary files a/assets/chrome.png and b/assets/chrome.png differ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java b/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java index c1c3204be..0452fc400 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/Chrome.java @@ -35,27 +35,28 @@ public class Chrome { }; public static NinePatch get( Type type ) { + String Asset = Assets.CHROME; switch (type) { case WINDOW: - return new NinePatch( Assets.CHROME, 0, 0, 22, 22, 7 ); + return new NinePatch( Asset, 0, 0, 20, 20, 6 ); case TOAST: - return new NinePatch( Assets.CHROME, 22, 0, 18, 18, 5 ); + return new NinePatch( Asset, 22, 0, 18, 18, 5 ); case TOAST_TR: - return new NinePatch( Assets.CHROME, 40, 0, 18, 18, 5 ); + return new NinePatch( Asset, 40, 0, 18, 18, 5 ); case BUTTON: - return new NinePatch( Assets.CHROME, 58, 0, 4, 4, 1 ); + return new NinePatch( Asset, 58, 0, 4, 4, 1 ); case TAG: - return new NinePatch( Assets.CHROME, 22, 18, 16, 14, 3 ); + return new NinePatch( Asset, 22, 18, 16, 14, 3 ); case GEM: - return new NinePatch( Assets.CHROME, 0, 32, 32, 32, 13 ); + return new NinePatch( Asset, 0, 32, 32, 32, 13 ); case SCROLL: - return new NinePatch( Assets.CHROME, 32, 32, 32, 32, 5, 11, 5, 11 ); + return new NinePatch( Asset, 32, 32, 32, 32, 5, 11, 5, 11 ); case TAB_SET: - return new NinePatch( Assets.CHROME, 64, 0, 22, 22, 7, 7, 7, 7 ); + return new NinePatch( Asset, 64, 0, 20, 20, 6, 6, 6, 6 ); case TAB_SELECTED: - return new NinePatch( Assets.CHROME, 64, 22, 10, 14, 4, 7, 4, 6 ); + return new NinePatch( Asset, 64, 22, 10, 14, 4, 7, 4, 6 ); case TAB_UNSELECTED: - return new NinePatch( Assets.CHROME, 74, 22, 10, 14, 4, 7, 4, 6 ); + return new NinePatch( Asset, 74, 22, 10, 14, 4, 7, 4, 6 ); default: return null; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index f59d8c411..e20ff82af 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -132,15 +132,12 @@ public class WndBag extends WndTabbed { for (Bag b : bags) { if (b != null) { BagTab tab = new BagTab( b ); - int tab_width = (slotsWidth-((bags.length-1)*5))/bags.length; - tab.setSize( tab_width, tabHeight() ); - - //no point in showing tabs if there's just one bag - if (bags.length > 1) add( tab ); - + add( tab ); tab.select( b == bag ); } } + + layoutTabs(); } public static WndBag lastBag( Listener listener, Mode mode, String title ) { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java index f274e172b..df12b2312 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndCatalogus.java @@ -102,9 +102,10 @@ public class WndCatalogus extends WndTabbed { } }; for (Tab tab : tabs) { - tab.setSize( TAB_WIDTH, tabHeight() ); add( tab ); } + + layoutTabs(); select( showPotions ? 0 : 1 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java index ae47f01f9..59aca3669 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndClass.java @@ -57,7 +57,6 @@ public class WndClass extends WndTabbed { add( tabMastery ); tab = new RankingTab( TXT_MASTERY, tabMastery ); - tab.setSize( TAB_WIDTH, tabHeight() ); add( tab ); resize( @@ -67,6 +66,8 @@ public class WndClass extends WndTabbed { resize( (int)tabPerks.width, (int)tabPerks.height ); } + layoutTabs(); + select( 0 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java index fa3663efb..1353187f7 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java @@ -83,11 +83,10 @@ public class WndHero extends WndTabbed { buffs.visible = buffs.active = selected; }; } ); - for (Tab tab : tabs) { - tab.setSize( TAB_WIDTH, tabHeight() ); - } - + resize( WIDTH, (int)Math.max( stats.height(), buffs.height() ) ); + + layoutTabs(); select( 0 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java index fc1f9fad7..59e896012 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java @@ -115,9 +115,10 @@ public class WndRanking extends WndTabbed { add( pages[i] ); Tab tab = new RankingTab( labels[i], pages[i] ); - tab.setSize( TAB_WIDTH, tabHeight() ); add( tab ); } + + layoutTabs(); select( 0 ); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java index 9c8ec9050..81056b4d0 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndTabbed.java @@ -39,9 +39,9 @@ public class WndTabbed extends Window { } protected Tab add( Tab tab ) { - + tab.setPos( tabs.size() == 0 ? - -chrome.marginLeft() + 1 : + -chrome.marginLeft() : tabs.get( tabs.size() - 1 ).right(), height ); tab.select( false ); super.add( tab ); @@ -100,6 +100,41 @@ public class WndTabbed extends Window { add( tab ); } } + + public void layoutTabs(){ + int fullWidth = width+chrome.marginHor(); + int numTabs = tabs.size(); + + if (numTabs == 0) + return; + if (numTabs == 1) { + tabs.get(0).setSize(fullWidth, tabHeight()); + return; + } + + int spaces = numTabs-1; + int spacing = -1; + + while (spacing == -1) { + for (int i = 0; i <= 5; i++){ + if ((fullWidth - i*(spaces)) % numTabs == 0) { + spacing = i; + break; + } + } + if (spacing == -1) fullWidth--; + } + + int tabWidth = (fullWidth - spacing*(numTabs-1)) / numTabs; + + for (int i = 0; i < tabs.size(); i++){ + tabs.get(i).setSize(tabWidth, tabHeight()); + tabs.get(i).setPos( i == 0 ? + -chrome.marginLeft() : + tabs.get( i - 1 ).right() + spacing, height ); + } + + } protected int tabHeight() { return 25;