diff --git a/README.md b/README.md index bc1fc6a..a5cfbda 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,12 @@ GoMule enabled for D2R ### Original GoMule App -http://gomule.sourceforge.net/ all credits go to Gohanman, Randall, Silospen, collaborators, ... +http://gomule.sourceforge.net/ all credits go to Gohanman, Randall, Silospen, collaborators, ... +- ***Update***: D2R support has been added to the official Gomule here https://gomule.sourceforge.io/ Original usage docs: https://managedway.dl.sourceforge.net/project/gomule/gomule/R0.31/GoMuleDocs.pdf -- ***WARNING***: Close D2R when using GoMule. D2R keeps character data open since it displays character gear in the menus and this prevents GoMule from saving files and moving items properly. -- ***NOTE***: A work-in-progress Atma .d2x stash to D2R .d2i stash converter is available here https://pairofdocs.github.io/atma-stash-d2r/ and discussions are [here](https://github.com/pairofdocs/gomule-d2r/issues/5) -- ***NOTE***: The D2R shared stash file `SharedStashSoftCoreV2.d2i` (or HardCore) can be viewed in Gomule-d2r but can't be modified since the format is not fully known yet -- ***NOTE***: Silospen is working on Gomule for D2R here: https://sourceforge.net/p/gomule/git/ci/d2rSupport/tree/ +- ***Warning***: Close D2R when using GoMule. D2R keeps character data open since it displays character gear in the menus and this prevents GoMule from saving files and moving items properly. +- ***Note***: A work-in-progress Atma .d2x stash to D2R .d2i stash converter is available here https://pairofdocs.github.io/atma-stash-d2r/ and discussions are [here](https://github.com/pairofdocs/gomule-d2r/issues/5) ### Install diff --git a/gomule/GoMule.jar b/gomule/GoMule.jar index a7bf0b1..0235f48 100644 Binary files a/gomule/GoMule.jar and b/gomule/GoMule.jar differ diff --git a/gomule/resources/background-sharedstash.jpg b/gomule/resources/background-sharedstash.jpg new file mode 100644 index 0000000..5dc6515 Binary files /dev/null and b/gomule/resources/background-sharedstash.jpg differ diff --git a/gomule/src/gomule/d2s/D2SharedStash.java b/gomule/src/gomule/d2s/D2SharedStash.java new file mode 100644 index 0000000..5d04c03 --- /dev/null +++ b/gomule/src/gomule/d2s/D2SharedStash.java @@ -0,0 +1,525 @@ +/******************************************************************************* + * + * Copyright 2007 Andy Theuninck, Randall & Silospen + * + * This file is part of gomule. + * + * gomule is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * gomule is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * gomlue; if not, write to the Free Software Foundation, Inc., 51 Franklin St, + * Fifth Floor, Boston, MA 02110-1301 USA + * + ******************************************************************************/ + +package gomule.d2s; + +import gomule.gui.*; +import gomule.item.*; +import gomule.util.*; + +import java.awt.Point; +import java.io.*; +import java.util.*; +import java.nio.*; + +import randall.d2files.*; + +//a character class +//manages one character file +//stores a filename, a bitreader +//to read from that file, and +//a vector of items +public class D2SharedStash extends D2ItemListAdapter +{ + public static final int BODY_STASH_CONTENT = 5; + public static final int STASHSIZEX = 30; // 10 orig. 10*3 for 3 tabs in the shared stash + public static final int STASHSIZEY = 10; + + private D2BitReader iReader; + // need iStashItems1, iStashItems2, iStashItems3 + private static final int NUM_SHARED_TABS = 3; + private ArrayList iStashes; + private ArrayList iStashItems1; + private ArrayList iStashItems2; + private ArrayList iStashItems3; + + private ArrayList lTabGolds; + + private D2Item iCharCursorItem; + + private String iCharName; + private String iTitleString = ""; // is called in D2ViewSharedStash, which already outputs D2R Shared Stash (SC or HC) + private String cClass; + private long iCharLevel; + private int curWep = 0; + private long lCharCode; + private String iCharClass; + private boolean iHC; + private boolean iSC; + + private File lFile; + + private boolean[][] iStashGrid; + // grid for stash tab2 and 3? + +// private int testCounter = 0; +// private boolean fullChanged = false; +// private ArrayList partialSetProps = new ArrayList(); +// private ArrayList fullSetProps = new ArrayList(); + + // private int lWoo; + + public D2SharedStash(String pFileName) throws Exception{ + super( pFileName ); + if ( iFileName == null || !iFileName.toLowerCase().endsWith(".d2i"))throw new Exception("Incorrect Stash file name"); + iStashes = new ArrayList(); + iStashItems1 = new ArrayList(); + iStashItems2 = new ArrayList(); + iStashItems3 = new ArrayList(); + iStashes.add(iStashItems1); + iStashes.add(iStashItems2); + iStashes.add(iStashItems3); + lTabGolds = new ArrayList(); + + lFile = new File(iFileName); + iSC = lFile.getName().toLowerCase().startsWith("sc_"); + iHC = lFile.getName().toLowerCase().startsWith("hc_"); + if ( !iSC && !iHC ){ + iSC = true; + iHC = true; + } + + iReader = new D2BitReader(iFileName); + readStash(); + // clear status + setModified(false); + } + + private void readStash() throws Exception{ + // 55 aa 55 aa header 4 bytes 00 4bytes version + iReader.set_byte_pos(8); + long lVersion = iReader.read(32); + // System.err.println("Version: " + lVersion ); + if (lVersion != 97)throw new Exception("Incorrect Shared Stash version: " + lVersion); + + // iReader.set_byte_pos(8); + // long lTabGold1 = iReader.read(32); // byte pos 12 + // if (iReader.get_length() != lSize)throw new Exception("Incorrect FileSize: " + lSize); + + // checksum. is checksum as byte pos 16? --> Yes. (checksum is only on the item block, not the gold#) + // long lCheckSum2 = calculateCheckSum(); + // iReader.set_byte_pos(16); + boolean lChecksum = false; + // byte lCalcByte3 = (byte) ((0xff000000 & lCheckSum2) >>> 24); + // byte lCalcByte2 = (byte) ((0x00ff0000 & lCheckSum2) >>> 16); + // byte lCalcByte1 = (byte) ((0x0000ff00 & lCheckSum2) >>> 8); + // byte lCalcByte0 = (byte) (0x000000ff & lCheckSum2); + // byte lFileByte0 = (byte) iReader.read(8); + // byte lFileByte1 = (byte) iReader.read(8); + // byte lFileByte2 = (byte) iReader.read(8); + // byte lFileByte3 = (byte) iReader.read(8); + // if (lFileByte0 == lCalcByte0){ + // if (lFileByte1 == lCalcByte1){ + // if (lFileByte2 == lCalcByte2){ + // if (lFileByte3 == lCalcByte3)lChecksum = true; + // } + // } + // } + // if (!lChecksum)throw new Exception("Incorrect Checksum"); + long lCheckSum = iReader.read(32); + +// long lWeaponSet = iReader.read(32); + + iStashGrid = new boolean[STASHSIZEY][STASHSIZEX]; // 3 tabs for shared stash pane + + clearGrid(); + int outBytePos = readItems(0, 0); + outBytePos = readItems(outBytePos, 1); + outBytePos = readItems(outBytePos, 2); + } + + + // Not used in D2R + // private long calculateCheckSum(){ + // iReader.set_byte_pos(0); + // long lCheckSum = 0; // unsigned integer checksum + // for (int i = 0; i < iReader.get_length(); i++){ + // long lByte = iReader.read(8); + // if (i >= 12 && i <= 15)lByte = 0; + // long upshift = lCheckSum << 33 >>> 32; + // long add = lByte + ((lCheckSum >>> 31) == 1 ? 1 : 0); + // lCheckSum = upshift + add; + // } + // return lCheckSum; + // } + + private int readItems(int bytePosStart, int iStashIdx) throws Exception{ + iReader.set_byte_pos(bytePosStart + 12); + long lTabGold1 = iReader.read(32); // byte pos 12 + lTabGolds.add(lTabGold1); + + int lFirstPos = iReader.findNextFlag("JM", bytePosStart); // byte pos 64 for 1st stash tab/item block + if (lFirstPos == -1)throw new Exception("Character items not found"); + int lLastItemEnd = lFirstPos + 2; // byte pos 66 + iReader.set_byte_pos(lLastItemEnd); + + int num_items = (int) iReader.read(16); + int lItemBlockStart = lFirstPos + 4; // byte pos 68 for 1st stash tab/item block + int lItemBlockEnd = lItemBlockStart; + + for (int i = 0; i < num_items; i++){ + // D2R d2s file doesn't have JM for each item. just 1JM at stat and 1 JM at end of item list + int lItemStart = lItemBlockEnd; + // update lItemStart for following items. use Bit position to start reading items + + D2Item lItem = new D2Item(iFileName, iReader, lItemStart, iCharLevel); + // debugging helper function added to D2Item.java lItem.get_bytes_string() + + lLastItemEnd = iReader.get_byte_pos(); // use itemReader for bits position + lItemBlockEnd = lLastItemEnd + 1; // add 1 to get to start nextItem byte, works for 2nd, 3rd, 4th... items + + if ( lItem.isCursorItem()){ + if ( iCharCursorItem != null )throw new Exception("Double cursor item found"); + iCharCursorItem = lItem; + }else{ + // add to itemlist1, 2 or 3 + addCharItem(lItem, iStashIdx); + markCharGrid(lItem, iStashIdx); + } + } + return lItemBlockEnd; + } + + + // handle itemlist 1, 2, and 3 + public ArrayList getItemList(){ + ArrayList lList = new ArrayList(); + if ( iStashes != null ) { + for (int i = 0; i < NUM_SHARED_TABS; i++) { + lList.addAll( iStashes.get(i) ); + } + } + return lList; + } + + public boolean containsItem(D2Item pItem){ + for (int i = 0; i < NUM_SHARED_TABS; i++) { + if ( iStashes.get(i).contains(pItem))return true; + } + // if ( iMercItems.contains(pItem))return true; + return false; + } + + public void removeItem(D2Item pItem){ + // need iStashes.get() then loop and remove + for (int i = 0; i < NUM_SHARED_TABS; i++) { + if ( iStashes.get(i).remove(pItem) ){ + unmarkCharGrid(pItem, i); + break; + } + } + setModified(true); + } + + // TODO: is this needed for a shared stash? can it be removed? + public void setCursorItem(D2Item pItem){ + iCharCursorItem = pItem; + setModified(true); + if ( iCharCursorItem != null ){ + iCharCursorItem.set_location((short) 4); + iCharCursorItem.set_body_position((short) 0); + } + } + // clear all the grids + // grids keep track of which spots that items + // can be place are occupied + public void clearGrid(){ + for (int i = 0; i < STASHSIZEY; i++){ + for (int j = 0; j < STASHSIZEX; j++)iStashGrid[i][j] = false; + } + } + + public boolean markCharGrid(D2Item i, int iStashIdx){ + short panel = i.get_panel(); + int row, col, width, height, j, k; + switch (panel){ + case 0: // equipped or on belt + + break; + case BODY_STASH_CONTENT: // stash + row = (int) i.get_row(); + col = (int) i.get_col(); + width = (int) i.get_width(); + height = (int) i.get_height(); + // TODO: check if col is input as 30 or as 10 for stash 3. row, col < 10 for items + if ((row + height) > 10)return false; // ***8*** stash size int and not a variable set here! + if ((col + width) > 30)return false; // ***6*** stash size + for (j = row; j < row + height; j++){ + for (k = col; k < col + width; k++)iStashGrid[j][k + iStashIdx*10] = true; + } + break; + } + return true; + } + + + public boolean unmarkCharGrid(D2Item i, int iStashIdx){ + short panel = i.get_panel(); + int row, col, width, height, j, k; + switch (panel){ + case 0: // equipped or on belt + + break; + case BODY_STASH_CONTENT: // stash + row = (int) i.get_row(); + col = (int) i.get_col(); + width = (int) i.get_width(); + height = (int) i.get_height(); + // TODO: check if col is input as 30 or as 10 for stash 3. item's row and col are < 10 + if ((row + height) > 10)return false; // orig > 8 + if ((col + width) > 10)return false; // orig > 6 + for (j = row; j < row + height; j++){ + for (k = col; k < col + width; k++) + iStashGrid[j][k + iStashIdx*10] = false; + } + break; + } + return true; + } + + + public void addCharItem(D2Item pItem, int iStashIdx){ + iStashes.get(iStashIdx).add(pItem); + // iStashItems1.add(pItem); + pItem.setCharLvl((int)iCharLevel); + setModified(true); + } + + public void removeCharItem(int i, int iStashIdx){ + // remove from stash1, 2, or 3 + iStashes.get(iStashIdx).remove(i); // input stashIdx then iStashes.get(stashIdx).remove(i) + setModified(true); + } + + + public boolean checkCharGrid(int panel, int x, int y, D2Item pItem){ + int i, j; + int w = pItem.get_width(); + int h = pItem.get_height(); + switch (panel){ + case BODY_STASH_CONTENT: + for (i = x; i < x + w; i++){ + for (j = y; j < y + h; j++){ + if (j >= iStashGrid.length || i >= iStashGrid[j].length || iStashGrid[j][i])return false; + } + } + break; + } + return true; + } + + + public boolean checkCharPanel(int panel, int x, int y, D2Item pItem){ + // System.err.println("checkCharPanel() x, y: " + x + " , " + y); // x,y: 29, 6 which is applicable to iStashGrid + switch (panel){ + case BODY_STASH_CONTENT: + if (y >= 0 && y < iStashGrid.length){ + if (x >= 0 && x < iStashGrid[y].length)return iStashGrid[y][x]; + } + return false; + } + return true; + } + + public int getCharItemIndex(int panel, int x, int y, int stashIdx){ // iRow, iCol are input + + // Add logic for checking stash1, 2 and 3 + for (int i = 0; i < iStashes.get(stashIdx).size(); i++){ + D2Item temp_item = (D2Item) iStashes.get(stashIdx).get(i); + if (temp_item.get_panel() == panel) { + // account for x pos (col) for stashes 2, 3 + int col = temp_item.get_col() + 10*stashIdx; + int row = temp_item.get_row(); + if ((x >= col) && (x <= col + temp_item.get_width() - 1) && (y >= row) && (y <= row + temp_item.get_height() - 1)) { + return i; + } + } + } + return -1; + } + + + public void saveInternal(D2Project pProject) + { + // backup file + D2Backup.backup(pProject, iFileName, iReader); + // build an a byte array that contains the + // entire item list and insert it into + // the open file in place of its current item list + // header for stash tabs. // int8 not uint8. 12-16 is gold, 16-20 is stash byte len, then JM and 2 bytes for itemNr + byte stashHeader[] = {85, -86, 85, -86, 0, 0, 0, 0, 97, 0, 0, 0, 0, 0, 0, 0, -58, 1, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 74, 77, 00, 00}; + + // total stash tab size. e.g. totalTabSize: 762 + int totalTabSize = 0; + for (int j = 0; j < NUM_SHARED_TABS ; j++){ + for (int i = 0; i < iStashes.get(j).size(); i++){ + byte[] item_bytes = ((D2Item) iStashes.get(j).get(i)).get_bytes(); + totalTabSize += item_bytes.length; + } + } + + byte[] lNewbytes = new byte[NUM_SHARED_TABS*stashHeader.length + totalTabSize]; // bytes of 3 stash tabs and 3 + + // write gold tab1 + System.arraycopy(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(lTabGolds.get(0).intValue()).array(), 0, stashHeader, 12, 4); + // write tab byte length, account for 85 bytes of header (includes JM and item count) + int lTabSize1 = 68; + for (int j = 0; j < iStashes.get(0).size(); j++){ + lTabSize1 += ((D2Item) iStashes.get(0).get(j)).get_bytes().length; + } + System.arraycopy(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(lTabSize1).array(), 0, stashHeader, 12+4, 4); + // write item number. stashIdx + // TODO: is uint16 needed here? + System.arraycopy(ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN).putShort((short)iStashes.get(0).size()).array(), 0, stashHeader, 66, 2); + // write items to lNewbytes (include header) + System.arraycopy(stashHeader, 0, lNewbytes, 0, stashHeader.length); + int lPos = stashHeader.length; + for (int i = 0; i < iStashes.get(0).size(); i++){ + byte[] item_bytes = ((D2Item) iStashes.get(0).get(i)).get_bytes(); + System.arraycopy(item_bytes, 0, lNewbytes, lPos, item_bytes.length); + lPos += item_bytes.length; + } + + // TODO: start from idx0, loop through all tabs + for (int tt = 1; tt < NUM_SHARED_TABS; tt++) { + lTabSize1 = 68; + // write gold + System.arraycopy(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(lTabGolds.get(tt).intValue()).array(), 0, stashHeader, 12, 4); + for (int j = 0; j < iStashes.get(tt).size(); j++){ + lTabSize1 += ((D2Item) iStashes.get(tt).get(j)).get_bytes().length; + } + // write tab byte length, account for 85 bytes of header (includes JM and item count) + System.arraycopy(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(lTabSize1).array(), 0, stashHeader, 12+4, 4); + // write item number. stashIdx + System.arraycopy(ByteBuffer.allocate(2).order(ByteOrder.LITTLE_ENDIAN).putShort((short)iStashes.get(tt).size()).array(), 0, stashHeader, 66, 2); + // write items to lNewbytes (include header) + System.arraycopy(stashHeader, 0, lNewbytes, lPos, stashHeader.length); + lPos = lPos + stashHeader.length; + for (int i = 0; i < iStashes.get(tt).size(); i++){ + byte[] item_bytes = ((D2Item) iStashes.get(tt).get(i)).get_bytes(); + System.arraycopy(item_bytes, 0, lNewbytes, lPos, item_bytes.length); + lPos += item_bytes.length; + } + } + + iReader.setBytes(lNewbytes); + iReader.set_byte_pos(0); + iReader.save(); + setModified(false); + } + +// public void setGold(int pGold) throws Exception{ +// if ( pGold < 0 )throw new Exception("gold must be greater than zero"); +// if ( pGold > getGoldMax())throw new Exception("gold must be smaller than max" + getGoldMax() ); +// setModified(true); +// } + +// public void setGoldBank(int pGoldBank) throws Exception{ +// if ( pGoldBank < 0 )throw new Exception("gold must be greater than zero"); +// if ( pGoldBank > getGoldBankMax())throw new Exception("gold must be smaller than max" + getGoldBankMax() ); +// setModified(true); +// } + +// public int getGoldBankMax(){ +// return 2500000; +// // int lMaxGold = 50000; +// // for ( int lLvl = 9 ; lLvl <=29 ; lLvl+=10 ){ +// // if ( iCharLevel < lLvl )return lMaxGold; +// // lMaxGold += 50000; +// // } +// // if ( iCharLevel == 30 )return 200000; +// // if ( iCharLevel == 31 )return 800000; +// // lMaxGold = 850000; +// // for ( int lLvl = 33 ; lLvl <=99 ; lLvl+=2 ){ +// // if ( iCharLevel <= lLvl )return lMaxGold; +// // lMaxGold += 50000; +// // } +// // return 0; +// } + + public void fullDump(PrintWriter pWriter){ + pWriter.println(fullDumpStr()); + } + + public String fullDumpStr(){ + StringBuffer out = new StringBuffer(); + + if ( iStashes != null ){ + // loop through 3 stash tabs, and items in each tab + for (int i = 0; i < NUM_SHARED_TABS; i++) { + for ( int j = 0 ; j < iStashes.get(i).size() ; j++) { + D2Item lItem = (D2Item) iStashes.get(i).get(j); + out.append(lItem.itemDump(true)); + out.append("\n"); + } + } + } + return out.toString(); + } + + + public D2Item getCharItem(int i, int stashIdx){ + return (D2Item) iStashes.get(stashIdx).get(i); + } + // Required method to implement + public void addItem(D2Item item){ + ; + } + // Required method to implement + public int getNrItems(){ + return -1; + } + public int getNrItems(int stashIdx){ + return iStashes.get(stashIdx).size(); + } // +size2, +size3 //old: + iMercItems.size() + + // public int getCharItemNr(){return iStashItems1.size();} + // public int getMercItemNr(){return iMercItems.size();} + // public int getCorpseItemNr(){return iCorpseItems.size();} + + // public Point[] getSkillLocs(){return iSkillLocs;} + // public int[] getSkillListA(){return cSkills[0];} + // public int[] getSkillListB(){return cSkills[1];} + // public int[] getSkillListC(){return cSkills[2];} + // public int[] getInitSkillListA(){return initSkills[0];} + // public int[] getInitSkillListB(){return initSkills[1];} + // public int[] getInitSkillListC(){return initSkills[2];} + + // public boolean[][][] getQuests(){return iQuests;} + // public boolean getCowKingDead(int difficulty){return cowKingDead[difficulty];} + // public boolean[][][] getWaypoints(){return iWaypoints;} + + // public int getGold(){return (int)iReadStats[14];} + // public int getGoldMax(){return 10000*((int) iCharLevel);} + // public int getGoldBank(){return (int)iReadStats[15];} + + public D2Item getCursorItem(){return iCharCursorItem;} + + public boolean isSC(){return !iHC;} + public boolean isHC(){return iHC;} + + public String getTitleString(){return iTitleString;} + public String getFilename() {return iFileName;} + public String getFileNameEnd(){ + return lFile.getName(); + } + +} \ No newline at end of file diff --git a/gomule/src/gomule/d2x/D2Stash.java b/gomule/src/gomule/d2x/D2Stash.java index 2589fca..a5b0d29 100644 --- a/gomule/src/gomule/d2x/D2Stash.java +++ b/gomule/src/gomule/d2x/D2Stash.java @@ -139,7 +139,7 @@ public void removeItem(D2Item pItem) { if (!d2rStash) { iItems.remove(pItem); - setModified(true); + setModified(true); } } @@ -242,7 +242,7 @@ private void readItems(long pNumItems) throws Exception lLastItemEnd = lItemStart + lItem.getItemLength(); iItems.add(lItem); } - if (d2rStash) { + if (d2rStash) { // **NOTE: this will not be needed since sharedstash*.d2i uses D2SharedStash.java now // while loop. find next JM and set position, then read items, can't do a recursive call to readItems since lLastItemEnd = 68 is hard-coded int lNextJM = iBR.findNextFlag("JM", lLastItemEnd); long numItems2 = 0; diff --git a/gomule/src/gomule/gui/D2FileManager.java b/gomule/src/gomule/gui/D2FileManager.java index ac62736..c724a88 100644 --- a/gomule/src/gomule/gui/D2FileManager.java +++ b/gomule/src/gomule/gui/D2FileManager.java @@ -70,6 +70,8 @@ public class D2FileManager extends JFrame private final static D2FileManager iCurrent = new D2FileManager(); private D2ViewClipboard iClipboard; private D2ViewStash iViewAll; + // TODO: is this needed for a d2r shared stash? + private D2ViewSharedStash iViewSharedAll; private boolean iIgnoreCheckAll = false; // private JMenuBar D2JMenu; // private JMenu file; @@ -104,7 +106,7 @@ public class D2FileManager extends JFrame int windowHeight = 768; // from D2ViewChar int BG_WIDTH = 626; - int BG_HEIGHT = 435; + int BG_HEIGHT = 435; // TODO: does this have to change for a wide- shared stash? 908 x 309 pixels public static D2FileManager getInstance() { @@ -410,6 +412,7 @@ private void flavieDump(ArrayList dFileNames, boolean singleDump){ if(((D2ItemContainer) iOpenWindows.get(iOpenWindows.indexOf(iDesktopPane.getSelectedFrame()))).getFileName().endsWith(".d2s")){ reportName = (((D2ViewChar)iOpenWindows.get(iOpenWindows.indexOf(iDesktopPane.getSelectedFrame()))).getChar().getCharName() + iProject.getReportName()); }else{ + // TODO: D2R shared stash and flavie report reportName = ((((D2ViewStash)iOpenWindows.get(iOpenWindows.indexOf(iDesktopPane.getSelectedFrame())))).getStashName() + iProject.getReportName()); // reportName = reportName.replace(".d2x", ""); // orig reportName = reportName.replace(".d2i", ""); @@ -1030,6 +1033,7 @@ public boolean projTxtDump(String pFileName, D2ItemList lList, String folder) if(lList.getFilename().endsWith(".d2s")){ lFileName = ((D2Character)lList).getCharName() + ".d2s"; }else{ + // TODO: account for D2R shared stash .d2i lFileName = ((D2Stash)lList).getFileNameEnd(); } lFileName = folder + File.separator + lFileName + ".txt"; @@ -1377,6 +1381,7 @@ public void internalFrameActivated(InternalFrameEvent arg0) { if (((D2ItemContainer) iOpenWindows.get(iOpenWindows.indexOf(iDesktopPane.getSelectedFrame()))).getFileName().endsWith("SharedStashSoftCoreV2.d2i") || ((D2ItemContainer) iOpenWindows.get(iOpenWindows.indexOf(iDesktopPane.getSelectedFrame()))).getFileName().endsWith("SharedStashHardCoreV2.d2i")) { pickFrom.setEnabled(false); + pickAll.setEnabled(false); pickChooser.setEnabled(false); dropTo.setEnabled(false); dropChooser.setEnabled(false); @@ -1522,21 +1527,48 @@ public void openStash(String pStashName, boolean load) lExisting = lItemContainer; } } - - D2ViewStash lStashView = null; - if(load){ - if (lExisting != null) - { - lStashView = ((D2ViewStash) lExisting); - } - else - { - lStashView = new D2ViewStash(D2FileManager.this, pStashName); - lStashView.setLocation(10 + (iOpenWindows.size() * 10), 10+ (iOpenWindows.size() * 10)); - addToOpenWindows(lStashView); + // add logic here to use D2ViewSharedStash() when filename == SharedStash*.d2i + if (!pStashName.endsWith("CoreV2.d2i")) { + D2ViewStash lStashView = null; + if(load){ + if (lExisting != null) { + lStashView = ((D2ViewStash) lExisting); + } + else { + lStashView = new D2ViewStash(D2FileManager.this, pStashName); + lStashView.setLocation(10 + (iOpenWindows.size() * 10), 10+ (iOpenWindows.size() * 10)); + addToOpenWindows(lStashView); + } + lStashView.activateView(); + internalWindowForward(lStashView); + } + }else { + if(load){ + if (lExisting != null) { + internalWindowForward(((JInternalFrame) lExisting)); + }else { + int BG_WIDTH2 = 908; // 908 x 309 pixels + int BG_HEIGHT2 = 309; + D2ViewSharedStash lSharedStashView = new D2ViewSharedStash(D2FileManager.this, pStashName); + if (iOpenWindows.size() == 0) { + lSharedStashView.setLocation(0, 0); // orig had: 10+ x, 10+ y + } else if (iOpenWindows.size() == 1) { + //BG_WIDTH = 626; //550; // TODO: update to 626 // from D2ViewChar + //BG_HEIGHT = 435; //383; // TODO: update to 457 + + lSharedStashView.setLocation((BG_WIDTH2 + 16), 0); + } else if (iOpenWindows.size() == 2) { + lSharedStashView.setLocation(0, BG_HEIGHT2 + 48); + } else if (iOpenWindows.size() == 3) { // will this be appropriate for 1920x1080 displays?. having the 3,4th windows go under 1st and 2nd + lSharedStashView.setLocation((BG_WIDTH2 + 16), BG_HEIGHT2 + 48); + } else { + // lSharedStashView.setLocation(20 + (iOpenWindows.size() * 10), 20 + (iOpenWindows.size() * 10)); // orig had: 10+ x, 10+ y + lSharedStashView.setLocation(((iOpenWindows.size()-4 +1) * 20), BG_HEIGHT2 + 48 + ((iOpenWindows.size()-4 +1) * 20)); + } + addToOpenWindows(lSharedStashView); + internalWindowForward(lSharedStashView); + } } - lStashView.activateView(); - internalWindowForward(lStashView); } iProject.addStash(pStashName); @@ -1597,6 +1629,21 @@ else if ( pFileName.toLowerCase().endsWith(".d2x") ) iItemLists.put(pFileName, lList); iViewProject.notifyItemListRead(pFileName); } + else if ( pFileName.endsWith("CoreV2.d2i") ) { + lList = new D2SharedStash(pFileName); + + int lType = getProject().getType(); + if ( lType == D2Project.TYPE_SC && (!lList.isSC() || lList.isHC()) ) + { + throw new Exception("Stash is not Softcore (SC), this is a project requirement"); + } + if ( lType == D2Project.TYPE_HC && (lList.isSC() || !lList.isHC()) ) + { + throw new Exception("Stash is not Hardcore (HC), this is a project requirement"); + } + iItemLists.put(pFileName, lList); + iViewProject.notifyItemListRead(pFileName); + } else if ( pFileName.toLowerCase().endsWith(".d2i") ) { lList = new D2Stash(pFileName); diff --git a/gomule/src/gomule/gui/D2ItemListAll.java b/gomule/src/gomule/gui/D2ItemListAll.java index 25f2a7a..a63ad3c 100644 --- a/gomule/src/gomule/gui/D2ItemListAll.java +++ b/gomule/src/gomule/gui/D2ItemListAll.java @@ -7,6 +7,7 @@ package gomule.gui; import gomule.d2s.D2Character; +import gomule.d2s.D2SharedStash; import gomule.d2x.D2Stash; import gomule.item.*; import gomule.util.*; @@ -123,7 +124,11 @@ public String getFilename(D2Item pItem) if(lItemList.getFilename().toLowerCase().endsWith(".d2s")){ return ((D2Character)lItemList).getCharName() + ".d2s"; }else{ - return ((D2Stash)lItemList).getFileNameEnd(); + if (lItemList.getFilename().endsWith("CoreV2.d2i")) { + return ((D2SharedStash)lItemList).getFileNameEnd(); + }else { + return ((D2Stash)lItemList).getFileNameEnd(); + } } } } diff --git a/gomule/src/gomule/gui/D2ViewSharedStash.java b/gomule/src/gomule/gui/D2ViewSharedStash.java new file mode 100644 index 0000000..83d1f90 --- /dev/null +++ b/gomule/src/gomule/gui/D2ViewSharedStash.java @@ -0,0 +1,1685 @@ +/******************************************************************************* + * + * Copyright 2007 Andy Theuninck, Randall & Silospen + * + * This file is part of gomule. + * + * gomule is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * gomule is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * gomlue; if not, write to the Free Software Foundation, Inc., 51 Franklin St, + * Fifth Floor, Boston, MA 02110-1301 USA + * + ******************************************************************************/ +package gomule.gui; + +import gomule.d2s.*; +import gomule.item.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import javax.swing.*; +import javax.swing.event.*; +import randall.util.*; + +/** + * @author Marco + * + */ +public class D2ViewSharedStash extends JInternalFrame implements D2ItemContainer, D2ItemListListener +{ + /** + * + */ + private static final long serialVersionUID = -7350581523641897831L; + private D2CharPainterPanel iCharPainter; + + // private D2CharCursorPainterPanel iCharCursorPainter; + private D2SharedStash iSharedStash; + + private JTextArea iMessage; + + private static final int BG_WIDTH = 908; // 626; //550; 908 x 309 pixels + private static final int BG_HEIGHT = 309; // 435; //383; + private static final int BG_CURSOR_WIDTH = 78; + private static final int BG_CURSOR_HEIGHT = 135; + + // change only the X positions for stash-left + inv-right. (add ~300 to inv, and subtract ~300 for stash) + // also search for hard coded pixel values + private static final int NUM_SHARED_TABS = 3; + private static final int STASH_X = 7; // 327 - 320 --> 7 + private static final int STASH_Y = 9; + + private static final int GRID_SIZE = 28; + private static final int GRID_SPACER = 1; + private static final int CURSOR_X = 12; + private static final int CURSOR_Y = 14; + + private String iFileName; + private D2FileManager iFileManager; + + private int iWeaponSlot = 1; + private int iSkillSlot = 0; + + private JTextField iGold; + private JTextField iGoldBank; + private JTextField iGoldMax; + private JTextField iGoldBankMax; + private JRadioButton iConnectGold; + private JRadioButton iConnectGoldBank; + private JTextField iTransferFree; + + private JButton iGoldTransferBtns[]; + private JTabbedPane lTabs = new JTabbedPane(); + + private JPopupMenu rightClickItem; + private MouseEvent rightClickEvent; + + public D2ViewSharedStash(D2FileManager pMainFrame, String pFileName) + { + super(pFileName, false, true, false, true); + + addInternalFrameListener(new InternalFrameAdapter() + { + public void internalFrameClosing(InternalFrameEvent e) + { + iFileManager.saveAll(); + closeView(); + } + }); + + ToolTipManager.sharedInstance().setDismissDelay(40000); + ToolTipManager.sharedInstance().setInitialDelay(300); +// ToolTip + + iFileManager = pMainFrame; + iFileName = pFileName; + + + + JPanel lCharPanel = new JPanel(); + lCharPanel.setLayout(new BorderLayout()); + iCharPainter = new D2CharPainterPanel(); + lCharPanel.add(iCharPainter, BorderLayout.CENTER); + lTabs.addTab("D2R Shared Stash", lCharPanel); + setContentPane(lTabs); + iCharPainter.build(); + + + + // JPanel lCursorPanel = new JPanel(); + // lCursorPanel.setLayout(new BorderLayout()); + // // TODO: is this needed for a shared stash? + // iCharCursorPainter = new D2CharCursorPainterPanel(); + // lCursorPanel.add(new JLabel("For item viewing, no items can be put or removed from here"), BorderLayout.NORTH); + + + + + ButtonGroup lConnectGroup = new ButtonGroup(); + + // TODO: implement bank buttons when saving the shared stash file is working + // RandallPanel lBankPanel = new RandallPanel(); + // iGold = new JTextField(); + // iGold.setEditable(false); + // iGoldMax = new JTextField(); + // iGoldMax.setEditable(false); + // iConnectGold = new JRadioButton(); + // lConnectGroup.add(iConnectGold); + + // iGoldBank = new JTextField(); + // iGoldBank.setEditable(false); + // iGoldBankMax = new JTextField(); + // iGoldBankMax.setEditable(false); + // iConnectGoldBank = new JRadioButton(); + // lConnectGroup.add(iConnectGoldBank); + // iConnectGoldBank.setSelected(true); + + // lBankPanel.addToPanel(new JLabel("Gold: "), 0, 0, 1, RandallPanel.NONE); + // lBankPanel.addToPanel(iConnectGold, 1, 0, 1, RandallPanel.NONE); + // lBankPanel.addToPanel(iGold, 2, 0, 1, RandallPanel.HORIZONTAL); + // lBankPanel.addToPanel(iGoldMax, 3, 0, 1, RandallPanel.HORIZONTAL); + // lBankPanel.addToPanel(new JLabel("Gold Stash: "), 0, 1, 1, RandallPanel.NONE); + // lBankPanel.addToPanel(iConnectGoldBank, 1, 1, 1, RandallPanel.NONE); + // lBankPanel.addToPanel(iGoldBank, 2, 1, 1, RandallPanel.HORIZONTAL); + // lBankPanel.addToPanel(iGoldBankMax, 3, 1, 1, RandallPanel.HORIZONTAL); + + // RandallPanel lTransferPanel = new RandallPanel(true); + // lTransferPanel.setBorder("Transfer"); + + // iGoldTransferBtns = new JButton[8]; + + // iGoldTransferBtns[0] = new JButton("to char"); + // iGoldTransferBtns[0].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferToChar(10000); + // } + // }); + // JTextField lField10000 = new JTextField("10.000"); + // lField10000.setEditable(false); + // iGoldTransferBtns[1] = new JButton("from char"); + // iGoldTransferBtns[1].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferFromChar(10000); + // } + // }); + + // iGoldTransferBtns[2] = new JButton("to char"); + // iGoldTransferBtns[2].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferToChar(100000); + // } + // }); + // JTextField lField100000 = new JTextField("100.000"); + // lField100000.setEditable(false); + // iGoldTransferBtns[3] = new JButton("from char"); + // iGoldTransferBtns[3].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferFromChar(100000); + // } + // }); + + // iGoldTransferBtns[4] = new JButton("to char"); + // iGoldTransferBtns[4].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferToChar(1000000); + // } + // }); + // JTextField lField1000000 = new JTextField("1.000.000"); + // lField1000000.setEditable(false); + // iGoldTransferBtns[5] = new JButton("from char"); + // iGoldTransferBtns[5].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferFromChar(1000000); + // } + // }); + + // iGoldTransferBtns[6] = new JButton("to char"); + // iGoldTransferBtns[6].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferToChar(getTransferFree()); + // } + // }); + // iTransferFree = new JTextField("10000"); + // iGoldTransferBtns[7] = new JButton("from char"); + // iGoldTransferBtns[7].addActionListener(new ActionListener() + // { + // public void actionPerformed(ActionEvent pEvent) + // { + // transferFromChar(getTransferFree()); + // } + // }); + + // lTransferPanel.addToPanel(iGoldTransferBtns[0], 0, 0, 1, RandallPanel.NONE); + // lTransferPanel.addToPanel(lField10000, 1, 0, 1, RandallPanel.HORIZONTAL); + // lTransferPanel.addToPanel(iGoldTransferBtns[1], 2, 0, 1, RandallPanel.NONE); + + // lTransferPanel.addToPanel(iGoldTransferBtns[2], 0, 1, 1, RandallPanel.NONE); + // lTransferPanel.addToPanel(lField100000, 1, 1, 1, RandallPanel.HORIZONTAL); + // lTransferPanel.addToPanel(iGoldTransferBtns[3], 2, 1, 1, RandallPanel.NONE); + + // lTransferPanel.addToPanel(iGoldTransferBtns[4], 0, 2, 1, RandallPanel.NONE); + // lTransferPanel.addToPanel(lField1000000, 1, 2, 1, RandallPanel.HORIZONTAL); + // lTransferPanel.addToPanel(iGoldTransferBtns[5], 2, 2, 1, RandallPanel.NONE); + + // lTransferPanel.addToPanel(iGoldTransferBtns[6], 0, 3, 1, RandallPanel.NONE); + // lTransferPanel.addToPanel(iTransferFree, 1, 3, 1, RandallPanel.HORIZONTAL); + // lTransferPanel.addToPanel(iGoldTransferBtns[7], 2, 3, 1, RandallPanel.NONE); + + // lBankPanel.addToPanel(lTransferPanel, 0, 10, 3, RandallPanel.HORIZONTAL); + + // lBankPanel.finishDefaultPanel(); + // lTabs.addTab("Bank", lBankPanel); + + + lTabs.addMouseListener(new MyMouse()); + + iMessage = new JTextArea(); + JScrollPane lScroll = new JScrollPane(iMessage); + RandallPanel lMessagePanel = new RandallPanel(); + JButton lConnect = new JButton("Connect"); + lConnect.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent pEvent) + { + connect(); + } + }); + JButton lDisconnect = new JButton("Disconnect"); + lDisconnect.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent pEvent) + { + disconnect(null); + } + }); + + lMessagePanel.addToPanel(lConnect, 0, 0, 1, RandallPanel.HORIZONTAL); + lMessagePanel.addToPanel(lDisconnect, 1, 0, 1, RandallPanel.HORIZONTAL); + lMessagePanel.addToPanel(lScroll, 0, 1, 2, RandallPanel.BOTH); + lTabs.addTab("Messages", lMessagePanel); + iMessage.setText("Nothing done, disconnected"); + + // TODO: implement item moving, deleting when saving the shared stash is working + // JMenuItem item; + // JMenuItem item2; + // JMenuItem item3; + // rightClickItem = new JPopupMenu(); + // rightClickItem.add(item = new JMenuItem("Delete?")); + // rightClickItem.add(item2 = new JMenuItem("View Item")); + // item3 = new JMenuItem("Extended Item Info"); + // rightClickItem.add(new JPopupMenu.Separator()); + // rightClickItem.add("Cancel"); + + // item.addActionListener(new ActionListener() { + // public void actionPerformed(ActionEvent event) { + + // if(event.getActionCommand().equals("Delete?")){ + + + + // D2ItemPanel lItemPanel = new D2ItemPanel(rightClickEvent, true, false, false); + // if (lItemPanel.getPanel() != -1) + // { + // // if there is an item to grab, grab it + // if (lItemPanel.isItem()) + // { + // D2Item lTemp = lItemPanel.getItem(); + + // int check = JOptionPane.showConfirmDialog(null, "Delete " + lTemp.getName() + "?"); + // if(check == 0){ + // iSharedStash.unmarkCharGrid(lTemp); + // iSharedStash.removeCharItem(lItemPanel.getItemIndex()); // iStashIdx needed + // setCursorDropItem(); + // // if(lTemp.statModding()){ + // // iSharedStash.updateCharStats("P", lTemp); + // // paintCharStats(); + // // } + // } + // } + // } + // } + + // } + // }); + + // item2.addActionListener(new ActionListener() { + // public void actionPerformed(ActionEvent event) { + + // if(event.getActionCommand().equals("View Item")){ + // D2ItemPanel lItemPanel = new D2ItemPanel(rightClickEvent, true, false, false); + // if (lItemPanel.getPanel() != -1) + // { + // // if there is an item to grab, grab it + // if (lItemPanel.isItem()) + // { + // D2Item lTemp = lItemPanel.getItem(); + // JFrame itemPanel = new JFrame(); + // JEditorPane report = new JEditorPane(); + // report.setContentType("text/html"); + + // JScrollPane SP = new JScrollPane(report); + // report.setBackground(Color.black); + // //HTMLEditorKit htmlEditor = new HTMLEditorKit(); + // //report.setEditorKit(htmlEditor); + // report.setForeground(Color.white); + // report.setText(""+lTemp.itemDumpHtml(true) + ""); + // report.setCaretPosition(0); + // itemPanel.add( SP); + + // itemPanel.setLocation((rightClickEvent.getComponent().getLocationOnScreen().x + rightClickEvent.getX()), (rightClickEvent.getComponent().getLocationOnScreen().y + rightClickEvent.getY())); + // itemPanel.setSize(200,400); + // itemPanel.setVisible(true); + // itemPanel.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + // } + // } + + + // } + + // } + // }); + +// item3.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent event) { + +// if(event.getActionCommand().equals("Extended Item Info")){ +// // D2ItemPanel lItemPanel = new D2ItemPanel(rightClickEvent, true, false, false); +// // if (lItemPanel.getPanel() != -1) +// // { +// // // if there is an item to grab, grab it +// // if (lItemPanel.isItem()) +// // { +// // D2Item lTemp = lItemPanel.getItem(); +// // Box v1 = Box.createVerticalBox(); + +// // Box h1 = Box.createHorizontalBox(); + +// // JTextPane report = new JTextPane(); +// // JScrollPane SP = new JScrollPane(report); +// // float[] bGrey = new float[3]; +// // bGrey = Color.RGBtoHSB(237, 237, 237, bGrey); +// // report.setBackground(Color.getHSBColor(bGrey[0], bGrey[1], bGrey[2])); +// // report.setForeground(Color.black); +// // report.setText(lTemp.itemDumpHtml(false)); +// // report.setCaretPosition(0); + +// // try{ +// // if(lTemp.isUnique() || lTemp.isSet() || lTemp.isRuneWord()){ +// // ArrayList perfect = lTemp.getPerfectString(); +// // JTextPane reportBest = new JTextPane(); +// // JScrollPane SPBest = new JScrollPane(reportBest); +// // reportBest.setBackground(Color.getHSBColor(bGrey[0], bGrey[1], bGrey[2])); +// // reportBest.setForeground(Color.black); +// // String bestStr = "BEST:\n\n"; +// // String[] perfDef = null; +// // if(lTemp.isTypeArmor()){ +// // perfDef = lTemp.getPerfectDef(perfect); +// // bestStr = bestStr + "Defense: " + perfDef[0] + "\n"; +// // }else if(lTemp.isTypeWeapon()){ +// // bestStr = bestStr + lTemp.getPerfectDmg(perfect)[1]; +// // } + +// // for(int x = 0;x 0) + // { + // try + // { + // // to char + // int lBank = iFileManager.getProject().getBankValue(); + // if (pGoldTransfer > lBank) + // { + // // don't allow more as the bank has + // pGoldTransfer = lBank; + // } + // int lGoldChar; + // int lGoldMax; + // if (iConnectGold.isSelected()) + // { + // lGoldChar = iSharedStash.getGold(); + // lGoldMax = iSharedStash.getGoldMax(); + // } + // else + // { + // lGoldChar = iSharedStash.getGoldBank(); + // lGoldMax = iSharedStash.getGoldBankMax(); + // } + // // char limit + // if (lGoldChar + pGoldTransfer > lGoldMax) + // { + // pGoldTransfer = lGoldMax - lGoldChar; + // } + // int lNewGold = lGoldChar + pGoldTransfer; + // int lNewGoldBank = lBank - pGoldTransfer; + // if (iConnectGold.isSelected()) + // { + // iSharedStash.setGold(lNewGold); + // iGold.setText(Integer.toString(iSharedStash.getGold())); + // } + // else + // { + // iSharedStash.setGoldBank(lNewGold); + // iGoldBank.setText(Integer.toString(iSharedStash.getGoldBank())); + // } + // iFileManager.getProject().setBankValue(lNewGoldBank); + // } + // catch (Exception pEx) + // { + // D2FileManager.displayErrorDialog(pEx); + // } + // } + + // } + + // public void transferFromChar(int pGoldTransfer) + // { + // if (pGoldTransfer > 0) + // { + // try + // { + // int lGoldChar; + // if (iConnectGold.isSelected()) + // { + // lGoldChar = iSharedStash.getGold(); + // } + // else + // { + // lGoldChar = iSharedStash.getGoldBank(); + // } + + // if (pGoldTransfer > lGoldChar) + // { + // // don't allow more as the char has + // pGoldTransfer = lGoldChar; + // } + + // // from char + // int lBank = iFileManager.getProject().getBankValue(); + + // int lNewGold = lGoldChar - pGoldTransfer; + // int lNewGoldBank = lBank + pGoldTransfer; + + // if (iConnectGold.isSelected()) + // { + // iSharedStash.setGold(lNewGold); + // iGold.setText(Integer.toString(iSharedStash.getGold())); + // } + // else + // { + // iSharedStash.setGoldBank(lNewGold); + // iGoldBank.setText(Integer.toString(iSharedStash.getGoldBank())); + // } + // iFileManager.getProject().setBankValue(lNewGoldBank); + // } + // catch (Exception pEx) + // { + // D2FileManager.displayErrorDialog(pEx); + // } + // } + + // } + + // public int getTransferFree() + // { + // try + // { + // return Integer.parseInt(iTransferFree.getText()); + // } + // catch (NumberFormatException e) + // { + // return 0; + // } + // } + + public boolean isHC() + { + return iSharedStash.isHC(); + } + + public boolean isSC() + { + return iSharedStash.isSC(); + } + + public String getFileName() + { + return iFileName; + } + + public boolean isModified() + { + return iSharedStash.isModified(); + } + + public D2ItemList getItemLists() + { + return iSharedStash; + } + + public void closeView() + { + disconnect(null); + iFileManager.removeFromOpenWindows(this); + } + + public void itemListChanged() + { + + String lTitle; + if ( iSharedStash == null ) + { + lTitle = "Disconnected"; + } + else + { + lTitle = "D2R Shared Stash"; + if (iSharedStash == null) + { + lTitle += " (Error Reading File)"; + } + else + { + lTitle += (( iSharedStash.isModified() ) ? "*" : ""); + if (iSharedStash.isSC()) + { + lTitle += " (SC)"; + } + else if (iSharedStash.isHC()) + { + lTitle += " (HC)"; + } + lTitle += iSharedStash.getTitleString(); + } + } + setTitle(lTitle); + iCharPainter.build(); + + // iCharCursorPainter.build(); // TODO: is this needed for a shared stash? + + } + + public void setCursorPickupItem() + { + setCursor(new Cursor(Cursor.HAND_CURSOR)); + } + + public void setCursorDropItem() + { + setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); + } + + public void setCursorNormal() + { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + + class MyMouse extends MouseAdapter{ + + public void mouseClicked(MouseEvent e){ + + if(lTabs.getSelectedIndex() == 6){ + dumpChar(); + } + + } + + } + + class D2ItemPanel + { + private boolean iIsChar; + private boolean iIsCursor; + private int iPanel; + private int iRow; + private int iCol; + private boolean iIsCorpse; + + public D2ItemPanel(MouseEvent pEvent, boolean pIsChar, boolean pIsCursor, boolean pIsCorpse) + { + iIsChar = pIsChar; + iIsCursor = pIsCursor; + iIsCorpse = pIsCorpse; + int x = pEvent.getX(); + int y = pEvent.getY(); + + iPanel = getMousePanel(x, y); + // pass info about stash tab 1, 2 or 3 to setRowCol + int stashIdx; + if (pEvent.getX() < 298) { + stashIdx = 0; + }else if (pEvent.getX() < 599) { + stashIdx = 1; + }else{ + stashIdx = 2; + } + if (pEvent.getX() > 296 && pEvent.getX() < 313) { // ***NOTE: hard-coded stash tab width here. + iPanel = -1; + }else if (pEvent.getX() > 598 && pEvent.getX() < 615) { // expand spacer between tabs to avoid exceptions with mouseMove + iPanel = -1; + } + setRowCol(x, y, stashIdx); + } + + public int getPanel() + { + return iPanel; + } + + public int getRow() + { + return iRow; + } + + public int getColumn() + { + return iCol; + } + + public boolean isItem() + { + // TODO: verify this is always false for a shared stash. there can't be a cursor item like there is for a character + if ( iIsCursor ) + { + return ( iSharedStash.getCursorItem() != null ); + } + // if (iIsChar) + // { + // return iSharedStash.checkCharPanel(iPanel, iRow, iCol, null); + // } + // TODO: verify this will not be needed for a shared stash. there is no merc and no corpse + // if(iIsCorpse) + // { + // return iSharedStash.checkCorpsePanel(iPanel,iRow, iCol, null); + // } + // return iSharedStash.checkMercPanel(iPanel, iRow, iCol, null); + + return iSharedStash.checkCharPanel(iPanel, iRow, iCol, null); + } + + public int getItemIndex(int iStashIdx) + { + // if (iIsChar) + // { + // return iSharedStash.getCharItemIndex(iPanel, iRow, iCol); + // } + // if (iIsCorpse) + // { + // return iSharedStash.getCorpseItemIndex(iPanel, iRow, iCol); + // } + // return iSharedStash.getMercItemIndex(iPanel, iRow, iCol); + // iStashIndex for stash tab 1, 2, or 3 + return iSharedStash.getCharItemIndex(iPanel, iRow, iCol, iStashIdx); + } + + public D2Item getItem(int stashIdx) + { + // TODO: verify item cannot be a cursor item for a shared stash + if ( iIsCursor ) + { + return iSharedStash.getCursorItem(); + } + + // if ( iIsChar ) + // { + // return iSharedStash.getCharItem(iSharedStash.getCharItemIndex(iPanel, iRow, iCol)); + // } + + // if(iIsCorpse){ + // return iSharedStash.getCorpseItem(iSharedStash.getCorpseItemIndex(iPanel, iRow, iCol)); + // } + // return iSharedStash.getMercItem(iSharedStash.getMercItemIndex(iPanel, iRow, iCol)); + return iSharedStash.getCharItem(iSharedStash.getCharItemIndex(iPanel, iRow, iCol, stashIdx), stashIdx); // iSharedStash.() , iStashIdx + // add 4th param to getCharItemIndex + } + + // calculate which panel (stash, inventory, equipment slot, etc) + // the coordinates x and y lie in + // belt_grid = panel 2 + // offset body positions by 10 + // return -1 on failure + private int getMousePanel(int x, int y) + { + if (iIsCursor) + { + if (iIsChar && x >= CURSOR_X && x < CURSOR_X + 2 * GRID_SIZE + 2 * GRID_SPACER && y >= CURSOR_Y && y < CURSOR_Y + 4 * GRID_SIZE + 4 * GRID_SPACER) + { + return D2Character.BODY_CURSOR; + } + return -1; + } // x > 7pixels and x < (7px + 10slots ) * 3 for 3 stash tabs + if (iIsChar && x >= STASH_X && x < NUM_SHARED_TABS*(STASH_X + 10 * GRID_SIZE + 10 * GRID_SPACER) && y >= STASH_Y && y < STASH_Y + 10 * GRID_SIZE + 10 * GRID_SPACER) + { + return D2Character.BODY_STASH_CONTENT; + } + + return -1; + } + + // get row/col + private void setRowCol(int x, int y, int stashIdx) + { + // int row, col; + // int temp_item = -1; + // non-equppied: calculate row and column + // then fetch the item if that item space + // has an item on it + if (iPanel < 10) + { + switch (iPanel) + { + case 1: // inventory + // iRow = (x - INV_X) / (GRID_SIZE + GRID_SPACER); + // iCol = (y - INV_Y) / (GRID_SIZE + GRID_SPACER); + // if (iChar.check_panel(panel, row, col)) + // { + // temp_item = iChar.get_item_index(panel, row, col); + // } + break; + case 2: // belted + // iRow = (x - BELT_GRID_X) / (GRID_SIZE + GRID_SPACER); + // iCol = 3 - ((y - BELT_GRID_Y) / (GRID_SIZE + GRID_SPACER)); + // if (iChar.check_panel(panel, row, col)) + // { + // temp_item = iChar.get_item_index(panel, col, row); + // } + break; + case 4: // cube + // iRow = (x - CUBE_X) / (GRID_SIZE + GRID_SPACER); + // iCol = (y - CUBE_Y) / (GRID_SIZE + GRID_SPACER); + // if (iChar.check_panel(panel, row, col)) + // { + // temp_item = iChar.get_item_index(panel, row, col); + // } + break; + case 5: // stash + // account for extra space between stash tabs 1, 2 and 3. 304px is a stash tab. padding between tab1 and 2 is ~12px + iRow = (x - STASH_X - stashIdx*(2*STASH_X)) / (GRID_SIZE + GRID_SPACER); + iCol = (y - STASH_Y) / (GRID_SIZE + GRID_SPACER); + // if (iChar.check_panel(panel, row, col)) + // { + // temp_item = iChar.get_item_index(panel, row, col); + // } + break; + } + } + // equipped + // row and column are irrelevant, so they can be zero + else + { // sharedStash items can only be in 'stash' -> case 5 + // iRow = 0; + // iCol = 0; + // if (iChar.check_panel(panel, 0, 0)) + // { + // temp_item = iChar.get_item_index(panel, 0, 0); + // } + } + // return temp_item; + } + + } + + class D2CharPainterPanel extends JPanel + { + /** + * + */ + private static final long serialVersionUID = 2159433491696507246L; + private Image iBackground; + + public D2CharPainterPanel() + { + setSize(BG_WIDTH, BG_HEIGHT); + Dimension lSize = new Dimension(BG_WIDTH, BG_HEIGHT); + setPreferredSize(lSize); + + addMouseListener(new MouseAdapter() + { + + + public void mouseReleased(MouseEvent pEvent) + { + if ( iSharedStash == null ) + { + return; + } + // System.err.println("Mouse Clicked: " + pEvent.getX() + ", + // " + pEvent.getY() ); + if (pEvent.getButton() == MouseEvent.BUTTON1 /* + * && + * pEvent.getClickCount() == + * 1 + */) + { + int lX = pEvent.getX(); + int lY = pEvent.getY(); + + // determine where the mouse click is. + // determine which stash is clicked based on x position (greater than multiple of stash width) + D2ItemPanel lItemPanel = new D2ItemPanel(pEvent, true, false, false); + if (lItemPanel.getPanel() != -1) + { + int stashIdx; + if (pEvent.getX() < 298) { + stashIdx = 0; + }else if (pEvent.getX() < 599) { + stashIdx = 1; + }else{ + stashIdx = 2; + } + // if there is an item to grab, grab it + if (lItemPanel.isItem()) + { + D2Item lTemp = lItemPanel.getItem(stashIdx); + + /**Code to remove potions when belt is removed! + * Thanks to Krikke. + */ + //System.out.println("isEquipped: " + lTemp.isEquipped() + " isABelt: " + lTemp.isABelt()); + + iSharedStash.unmarkCharGrid(lTemp, stashIdx); + iSharedStash.removeCharItem(lItemPanel.getItemIndex(stashIdx), stashIdx); + D2ViewClipboard.addItem(lTemp); + setCursorDropItem(); + // if(lTemp.statModding()){ + // iSharedStash.updateCharStats("P", lTemp); + // } + +// // redraw +// build(); +// repaint(); + } + else if (D2ViewClipboard.getItem() != null) + { + // System.err.println("Drop item"); + // since there is an item on the mouse, try to + // drop it here + + D2Item lDropItem = D2ViewClipboard.getItem(); + // int lDropWidth = lDropItem.get_width(); + // int lDropHeight = lDropItem.get_height(); + // int r = 0, c = 0; + boolean drop = false; + // non-equipped items, handle differently + // because they require a row and column + if (lItemPanel.getPanel() < 10) + { + // calculate row and column for the given + // panel + // with mouse coords x and y (split into an + // int for + // convenience) + // int temp = find_grid(panel, x, y); + // r = temp >> 16; + // c = temp & 0xffff; + // r -= (D2MouseItem.get_mouse_x() / + // GRID_SIZE); + // c -= (D2MouseItem.get_mouse_y() / + // GRID_SIZE); + // if that area of the character is empty, + // then update fields of the item and set + // the 'drop' variable to true + if (iSharedStash.checkCharGrid(lItemPanel.getPanel(), lItemPanel.getRow(), lItemPanel.getColumn(), lDropItem)) + { + switch (lItemPanel.getPanel()) + { + case 2: + lDropItem.set_location((short) 2); + lDropItem.set_body_position((short) 0); + lDropItem.set_col((short) (4 * lItemPanel.getColumn() + lItemPanel.getRow())); + lDropItem.set_row((short) 0); + lDropItem.set_panel((short) 0); + break; + case 1: + case 4: + case 5: + lDropItem.set_location((short) 0); + lDropItem.set_body_position((short) 0); + lDropItem.set_row((short) lItemPanel.getColumn()); + lDropItem.set_col((short) (lItemPanel.getRow() - 10*stashIdx)); // getRow outputs the 'x' pos + lDropItem.set_panel((short) lItemPanel.getPanel()); + break; + } + drop = true; + } + } + // equipped items, a bit simpler + // if that equipment slot is empty, update the + // item's fields and set drop to true + // r and c are set to width and height + // for find_corner to deal with variable-size + // objects in the hands + // (note lack of item-type checking) + else + { + if (!iSharedStash.checkCharPanel(lItemPanel.getPanel(), 0, 0, lDropItem)) + { + lDropItem.set_location((short) 1); + lDropItem.set_body_position((short) (lItemPanel.getPanel() - 10)); + lDropItem.set_col((short) 0); + lDropItem.set_row((short) 0); + lDropItem.set_panel((short) 0); + drop = true; + // r = lDropWidth; + // c = lDropHeight; + } + } + // if the space to set the item is empty + if (drop) + { + iSharedStash.markCharGrid(lDropItem, stashIdx); + // move the item to a new charcter, if + // needed + iSharedStash.addCharItem(D2ViewClipboard.removeItem(), stashIdx); + + // redraw +// build(); +// repaint(); + + setCursorPickupItem(); + // if(lDropItem.statModding()){ + // iSharedStash.updateCharStats("D", lDropItem); + // paintCharStats(); + // } + //my_char.show_grid(); + } + } + } + } + // TODO: implement deleting, moving items when saving shared stash file works + // else if (pEvent.getButton() == MouseEvent.BUTTON3){ + // D2ItemPanel lItemPanel = new D2ItemPanel(pEvent, true, false, false); + // if (lItemPanel.getPanel() != -1) + // { + // if (lItemPanel.isItem()) + // { + + // rightClickItem.show(D2ViewSharedStash.this, pEvent.getX(), pEvent.getY()+35); + // rightClickEvent = pEvent; + // } + // } + // } + } + + + + public void mouseEntered(MouseEvent e) + { + setCursorNormal(); + } + + public void mouseExited(MouseEvent e) + { + setCursorNormal(); + } + }); + addMouseMotionListener(new MouseMotionAdapter() + { + public void mouseMoved(MouseEvent pEvent) + { + if ( iSharedStash == null ) + { + return; + } + // restoreSubcomponentFocus(); + D2Item lCurrentMouse = null; + + D2ItemPanel lItemPanel = new D2ItemPanel(pEvent, true, false, false); + if (lItemPanel.getPanel() != -1) + { + if (lItemPanel.isItem()) + { + int stashIdx; + if (pEvent.getX() < 298) { + stashIdx = 0; + }else if (pEvent.getX() < 599) { // NOTE: hard-coded px values. also see D2ItemPanel + stashIdx = 1; + }else{ + stashIdx = 2; + } + lCurrentMouse = lItemPanel.getItem(stashIdx); // get x-pos of mouse to set stashIdx + } + + if (lItemPanel.isItem()) + { + setCursorPickupItem(); + } + else + { + if (D2ViewClipboard.getItem() == null) + { + setCursorNormal(); + } + else + { + D2Item lDropItem = D2ViewClipboard.getItem(); + // int lDropWidth = lDropItem.get_width(); + // int lDropHeight = lDropItem.get_height(); + + boolean drop = false; + + if (lItemPanel.getPanel() < 10) + { + if (iSharedStash.checkCharGrid(lItemPanel.getPanel(), lItemPanel.getRow(), lItemPanel.getColumn(), lDropItem)) + { + drop = true; + } + } + else + { + if (!iSharedStash.checkCharPanel(lItemPanel.getPanel(), 0, 0, lDropItem)) + { + drop = true; + } + } + if (drop) + { + setCursorDropItem(); + } + else + { + setCursorNormal(); + } + } + } + } + else + { + setCursorNormal(); + } + if (lCurrentMouse == null) + { + D2CharPainterPanel.this.setToolTipText(null); + } + else + { + D2CharPainterPanel.this.setToolTipText(lCurrentMouse.itemDumpHtml(false)); + } + } + }); + } + + // not used for a shared stash + public void setWeaponSlot(int pWeaponSlot) + { + if(iWeaponSlot == pWeaponSlot){ + return; + } + + iWeaponSlot = pWeaponSlot; + build(); + //REMOVE ITEMS AND ADD ITEMS + + + } + + public void build() + { + Image lEmptyBackground; + if (iWeaponSlot == 1) + { + lEmptyBackground = D2ImageCache.getImage("background-sharedstash.jpg"); //background_10x10 + } + else + { + lEmptyBackground = D2ImageCache.getImage("background-sharedstash.jpg"); //background2_10x10 + } + + int lWidth = lEmptyBackground.getWidth(D2CharPainterPanel.this); + int lHeight = lEmptyBackground.getHeight(D2CharPainterPanel.this); + + iBackground = iFileManager.getGraphicsConfiguration().createCompatibleImage(lWidth, lHeight, Transparency.BITMASK); +// iBackground = new BufferedImage(lWidth, lHeight, BufferedImage.TYPE_3BYTE_BGR); + + Graphics2D lGraphics = (Graphics2D) iBackground.getGraphics(); + + lGraphics.drawImage(lEmptyBackground, 0, 0, D2CharPainterPanel.this); + + if ( iSharedStash != null ) + { // draw the item for stash 1, 2 or 3 + for (int j = 0; j < NUM_SHARED_TABS; j++) { + for (int i = 0; i < iSharedStash.getNrItems(j); i++) + { + D2Item temp_item = iSharedStash.getCharItem(i, j); + Image lImage = D2ImageCache.getDC6Image(temp_item); + int location = temp_item.get_location(); + // on one of the grids + // these items have varying height and width + // and a variable position, indexed from the + // top left + if (location == 0) + { + int panel = temp_item.get_panel(); + int x = temp_item.get_col(); + int y = temp_item.get_row(); + // int w = temp_item.get_width(); + // int h = temp_item.get_height(); + switch (panel) + { + // in the inventory + case 1: + // System.err.println("Item loc 0 - 1 - " + + // temp_item.get_name() + " - " + temp_item.get_image() + // ); + // lGraphics.drawImage(lImage, INV_X + x * GRID_SIZE + x * GRID_SPACER, INV_Y + y * GRID_SIZE + y * GRID_SPACER, D2CharPainterPanel.this); + break; + // in the cube + case 4: + // lGraphics.drawImage(lImage, CUBE_X + x * GRID_SIZE + x * GRID_SPACER, CUBE_Y + y * GRID_SIZE + y * GRID_SPACER, D2CharPainterPanel.this); + break; + // in the stash + case 5: + lGraphics.drawImage(lImage, STASH_X + 304*j +x * GRID_SIZE + x * GRID_SPACER, STASH_Y + y * GRID_SIZE + y * GRID_SPACER, D2CharPainterPanel.this); + break; + } + } + // on the belt + // belt row and col is indexed from the top + // left, but this displays them from the + // bottom right (so the 0th row items get + // placed in the bottom belt row) + // these items can all be assumed to be 1x1 + else if (location == 2) + { + // int x = temp_item.get_col(); + // int y = x / 4; + // x = x % 4; + // lGraphics.drawImage(lImage, BELT_GRID_X + x * GRID_SIZE + x * GRID_SPACER, BELT_GRID_Y + (3 - y) * GRID_SIZE + (3 - y) * GRID_SPACER, D2CharPainterPanel.this); + } + // on the body + else + { + int body_position = temp_item.get_body_position(); + int w, h, wbias, hbias; + switch (body_position) + { + // head (assume 2x2) + case 1: + + break; + // neck / amulet (assume 1x1) + case 2: + + break; + case 3: + // body (assume 2x3 + + break; + // right arm (give the whole 2x4) + // biases are to center non-2x4 items + case 4: + case 11: + + break; + // left arm (give the whole 2x4) + case 5: + case 12: + + break; + // left ring (assume 1x1) + case 6: + + break; + // right ring (assume 1x1) + case 7: + + break; + // belt (assume 2x1) + case 8: + + break; + case 9: + // boots (assume 2x2) + + break; + // gloves (assume 2x2) + case 10: + + break; + } + } + } + } + + } + repaint(); + } + + public void paint(Graphics pGraphics) + { + super.paint(pGraphics); + Graphics2D lGraphics = (Graphics2D) pGraphics; + + lGraphics.drawImage(iBackground, 0, 0, D2CharPainterPanel.this); + } + } + + //TODO: is the char cursorpainter needed for a shared stash? +// class D2CharCursorPainterPanel extends JPanel +// { +// /** +// * +// */ +// private static final long serialVersionUID = 3335835168313769724L; +// private Image iBackground; + +// public D2CharCursorPainterPanel() +// { +// setSize(BG_CURSOR_WIDTH, BG_CURSOR_HEIGHT); +// Dimension lSize = new Dimension(BG_CURSOR_WIDTH, BG_CURSOR_HEIGHT); +// setPreferredSize(lSize); + +// addMouseListener(new MouseAdapter() +// { +// public void mouseReleased(MouseEvent pEvent) +// { +// if ( iSharedStash == null ) +// { +// return; +// } +// // System.err.println("Mouse Clicked: " + pEvent.getX() + ", +// // " + pEvent.getY() ); +// if (pEvent.getButton() == MouseEvent.BUTTON1 /* +// * && +// * pEvent.getClickCount() == +// * 1 +// */) +// { +// // determine where the mouse click is +// D2ItemPanel lItemPanel = new D2ItemPanel(pEvent, true, true, false); +// if (lItemPanel.getPanel() != -1) +// { +// // if there is an item to grab, grab it +// if (lItemPanel.isItem()) +// { +// D2Item lTemp = iSharedStash.getCursorItem(); +// iSharedStash.setCursorItem(null); +// D2ViewClipboard.addItem(lTemp); +// setCursorDropItem(); + +// // redraw +// build(); +// repaint(); +// } +// else if (D2ViewClipboard.getItem() != null) +// { +// iSharedStash.setCursorItem(D2ViewClipboard.removeItem()); +// build(); +// repaint(); + +// setCursorPickupItem(); +// } +// } + +// // // MBR: for now, disable dropping completely, +// // // it's not working +// // // // System.err.println("Drop item"); +// // // // since there is an item on the mouse, try +// // // to drop it here +// // // +// // // D2Item lDropItem = D2MouseItem.getItem(); +// // //// int lDropWidth = lDropItem.get_width(); +// // //// int lDropHeight = lDropItem.get_height(); +// // // // int r = 0, c = 0; +// // // boolean drop = false; +// // // // non-equipped items, handle differently +// // // // because they require a row and column +// // // // equipped items, a bit simpler +// // // // if that equipment slot is empty, update +// // // the +// // // // item's fields and set drop to true +// // // // r and c are set to width and height +// // // // for find_corner to deal with variable-size +// // // // objects in the hands +// // // // (note lack of item-type checking) +// // // if +// // // (!iChar.checkCharPanel(lItemPanel.getPanel(), +// // // 0, 0, lDropItem)) +// // // { +// // // lDropItem.set_location((short) 1); +// // // lDropItem.set_body_position((short) +// // // (lItemPanel.getPanel() - 10)); +// // // lDropItem.set_col((short) 0); +// // // lDropItem.set_row((short) 0); +// // // lDropItem.set_panel((short) 0); +// // // drop = true; +// // //// r = lDropWidth; +// // //// c = lDropHeight; +// // // } +// // // // if the space to set the item is empty +// // // if (drop) +// // // { +// // // iChar.markCharGrid(lDropItem); +// // // // move the item to a new charcter, if needed +// // // iChar.addCharItem(D2MouseItem.removeItem()); +// // // +// // // setModified( true ); +// // // +// // // // redraw +// // // build(); +// // // repaint(); +// // // +// // // setCursorPickupItem(); +// // // //my_char.show_grid(); +// // // } +// // } +// // } +// } +// } + +// public void mouseEntered(MouseEvent e) +// { +// setCursorNormal(); +// } + +// public void mouseExited(MouseEvent e) +// { +// setCursorNormal(); +// } +// }); +// addMouseMotionListener(new MouseMotionAdapter() +// { +// public void mouseMoved(MouseEvent pEvent) +// { +// if ( iSharedStash == null ) +// { +// return; +// } +// // restoreSubcomponentFocus(); +// D2Item lCurrentMouse = null; + +// D2ItemPanel lItemPanel = new D2ItemPanel(pEvent, true, true, false); +// if (lItemPanel.getPanel() != -1) +// { +// if (lItemPanel.isItem()) +// { +// lCurrentMouse = lItemPanel.getItem(); +// } + +// if (lItemPanel.isItem()) +// { +// setCursorPickupItem(); +// } +// else +// { +// if (D2ViewClipboard.getItem() == null) +// { +// setCursorNormal(); +// } +// else +// { +// // setCursorNormal(); +// setCursorDropItem(); + +// // MBR: for now, disable dropping completely +// // D2Item lDropItem = D2ViewClipboard.getItem(); +// // // int lDropWidth = lDropItem.get_width(); +// // // int lDropHeight = lDropItem.get_height(); + +// // boolean drop = false; + +// // if (!iChar.checkCharPanel(lItemPanel.getPanel(), 0, 0, lDropItem)) +// // { +// // drop = true; +// // } +// // if (drop) +// // { +// // setCursorDropItem(); +// // } +// // else +// // { +// // setCursorNormal(); +// // } +// } +// } +// } +// else +// { +// setCursorNormal(); +// } +// if (lCurrentMouse == null) +// { +// D2CharCursorPainterPanel.this.setToolTipText(null); +// } +// else +// { +// D2CharCursorPainterPanel.this.setToolTipText(lCurrentMouse.itemDumpHtml(false)); +// } +// } +// }); +// } + +// public void build() +// { +// Image lEmptyBackground = D2ImageCache.getImage("cursor.jpg"); + +// int lWidth = lEmptyBackground.getWidth(D2CharCursorPainterPanel.this); +// int lHeight = lEmptyBackground.getHeight(D2CharCursorPainterPanel.this); + +// iBackground = iFileManager.getGraphicsConfiguration().createCompatibleImage(lWidth, lHeight, Transparency.BITMASK); + +// Graphics2D lGraphics = (Graphics2D) iBackground.getGraphics(); + +// lGraphics.drawImage(lEmptyBackground, 0, 0, D2CharCursorPainterPanel.this); + +// if ( iSharedStash != null ) +// { +// D2Item lCursorItem = iSharedStash.getCursorItem(); +// if ( lCursorItem != null ) +// { +// Image lImage = D2ImageCache.getDC6Image(lCursorItem); +// lGraphics.drawImage(lImage, CURSOR_X, CURSOR_Y, D2CharCursorPainterPanel.this); +// } +// } +// repaint(); +// } + +// public void paint(Graphics pGraphics) +// { +// super.paint(pGraphics); +// Graphics2D lGraphics = (Graphics2D) pGraphics; + +// lGraphics.drawImage(iBackground, 0, 0, D2CharCursorPainterPanel.this); +// } +// } + + public void dumpChar() { + // not needed for shared D2R stash. there is no "dumpChar" tab at the top of the window + String iChaString = iSharedStash.fullDumpStr().replaceAll("
", "\n"); + // lDump.setText(iChaString); + // lDump.setCaretPosition(0); + // lDump.validate(); + } + + public D2SharedStash getChar(){ + return iSharedStash; + } + + // public void putOnCharacter(int areaCode, ArrayList dropList){ + + // iSharedStash.ignoreItemListEvents(); + // int dPanel = 0; + // int rMax = 0; + // int cMax = 0; + // switch(areaCode){ + // case 0: + // //stash + // dPanel = 5; + // rMax = D2Character.STASHSIZEY; + // cMax = D2Character.STASHSIZEX; + // break; + // case 1: + // //inv + // dPanel = 1; + // rMax = D2Character.INVSIZEY; + // cMax = D2Character.INVSIZEX; + // break; + // case 2: + // //cube + // dPanel = 4; + // rMax = D2Character.CUBESIZEY; + // cMax = D2Character.CUBESIZEX; + // break; + // } + // try{ + // for(int z = dropList.size()-1; z> -1;z--){ + // D2Item lDropItem = (D2Item) dropList.get(z); + // for(int x = 0;x", ""); - if(!isStash()){ + if(!isStash()){ // isStash --> !'all' stash iItemText.setText("Item From: "+(((D2ItemListAll) iStash).getFilename(iItemModel.getItem(iTable.getSelectedRow())))+"

"+dispStr+"
"); }else{ iItemText.setText(""+dispStr+""); @@ -549,7 +552,7 @@ public void actionPerformed(ActionEvent pEvent) { public void actionPerformed(ActionEvent pEvent) { - if (!((D2Stash) iStash).d2rStash) { + if (iFileName.equals("all") || !((D2Stash) iStash).d2rStash) { // TODO d2rStash bool is not used for d2r shared stashes. they are type D2SharedStash Vector lItemList = new Vector(); int lRows[] = iTable.getSelectedRows(); @@ -565,13 +568,16 @@ public void actionPerformed(ActionEvent pEvent) iStash.ignoreItemListEvents(); for (int i = 0; i < lItemList.size(); i++) { - int check = JOptionPane.showConfirmDialog(null, "Delete " + ((D2Item) lItemList.get(i)).getName() + "?"); - - if(check == 0){ - iStash.removeItem((D2Item) lItemList.get(i)); - } + if ( !(((D2Item) lItemList.get(i)).getFileName().endsWith("CoreV2.d2i")) ) { + int check = JOptionPane.showConfirmDialog(null, "Delete " + ((D2Item) lItemList.get(i)).getName() + "?"); + + if(check == 0){ + iStash.removeItem((D2Item) lItemList.get(i)); + } + }else { + JOptionPane.showMessageDialog(null, "Deleting an item from D2R's Shared Stash is disabled in the 'all' stash window", "Warning", JOptionPane.INFORMATION_MESSAGE); + } } - } finally {