Skip to content

Commit

Permalink
reorganize resources and add txt file to allow for localization and c…
Browse files Browse the repository at this point in the history
…ustomizations

fix patch 2.4 name reading/writing
update tests
  • Loading branch information
WalterCouto committed Apr 26, 2022
1 parent a748a31 commit a6af080
Show file tree
Hide file tree
Showing 407 changed files with 583,110 additions and 28,823 deletions.
Binary file modified D2Editor.exe
Binary file not shown.
Binary file modified UserGuide.pdf
Binary file not shown.
16 changes: 14 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ______________________________________________
### How To Use

1. Run the D2Editor.exe file<br>
2. Open a Diablo II character file (press CTRL-O or click on File, Open) which is located in the "save" directory of where you installed Diablo II.<br>
2. Open a Diablo II character file (press CTRL-O or click on File, Open) which is located in the "save" directory of where you installed Diablo II Resurrected.<br>
3. Make changes (type in a value if editing level, gold, experience, etc. or use the mouse if changing title, class, or state)<br>
4. Save changes (press CTRL-S or click on File, Save)<br>
5. Play Diablo II.<br>
Expand Down Expand Up @@ -48,7 +48,7 @@ You can edit the following stats:<br>

### Known Issues

- Tested with Diablo II Resurrected v1.1.67554 and Diablo II Classic v1.14d (It has unit test confirming it supports the older versions from v1.00 through to v1.09 as well but the files used in testing have not been tested in a real game)**
- Tested with Diablo II Resurrected v1.2.68992 (PTR 2.4) and Diablo II Classic v1.14d (It has unit test confirming it supports the all versions from v1.00 and up as well but the files used in testing have not been tested in a real game)**
- Starting with Diablo II Classic V1.13c the maximum gold in your stash no longer depends on yoru character's level, and is now a flat cap of 2,500,000 instead. The editor will now use this value when editing Ressurrected files or Classic files marked as v1.10 or higher when determining the limit for your gold in your stash.
- You must close the character file before playing Diablo II. This is because there are no options to enable file sharing for the read and write functions I'm using in ANSI C++.

Expand All @@ -65,15 +65,27 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE<br>
### Useful Links

* https://github.com/zhaoleimxd/JamellaD2E<br>
* https://github.com/daidodo/diablo_edit<br>
* https://github.com/dschu012/D2SLib<br>
* https://github.com/squeek502/d2itemreader<br>
* https://github.com/nokka/d2s<br>
* https://github.com/krisives/d2s-format<br>
* https://tristram-archives.github.io/diablo2_infodump//2013/just%20hosting%20these,%20Downloaded%20from%20Internet/documentation/d2s_save_file_format_1.13d.html<br>
* https://github.com/andersgong/d2bin2txt/<br>
* https://diablo.antikrist.org/item-codes/<br>
* [d2s Binary File Format](d2s_File_Format.md)<br>

### Revision History
**Version 2.15 (April 26, 2022)**
- Updated: Reorganize resources and add txt file to allow for future localization and customizations.<br>
- Updated: Create GPS Dialog now chooses a beltable item by default when launched from the belt inventory.<br>
- Updated: Fixed some bugs related to item tooltip strings<br>
- Updated: Fixed bugs retrieving skill names for magical attributes for non-character specific skills<br>
- Updated: Fixed D2R items with realm GUID. D2R now stores 128 bits instead of the 96 bits for realm GUID<br>
- Updated: Properly calculate the displayed requirements for items. (level, dexterity and Strength)<br>
- Updated: Fixed player name reading for PTR2.4 and allow use of UTF-8 characters in player name<br>
<br>

**Version 2.14 (Mar 11, 2022)**
- Updated: Updated jewel alternate images.<br>
- Updated: Updated item context menus across forms showing items.<br>
Expand Down
65 changes: 51 additions & 14 deletions source/D2AddGemsForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "D2Editor.h"
#include "D2AddGemsForm.h"
#include "afxdialogex.h"
#include "d2ce\helpers\ItemHelpers.h"
#include "d2ce/helpers/ItemHelpers.h"
#include <utf8/utf8.h>

#ifdef _DEBUG
#define new DEBUG_NEW
Expand All @@ -38,7 +39,14 @@ namespace
return _T("");
}

return CString(itemType.name.c_str());
auto uName = utf8::utf8to16(itemType.name);
return CString(reinterpret_cast<LPCWSTR>(uName.c_str()));
}

bool IsBeltableFromCode(const std::array<std::uint8_t, 4>& gemCode)
{
const auto& itemType = d2ce::ItemHelpers::getItemTypeHelper(gemCode);
return itemType.isBeltable();
}
}

Expand Down Expand Up @@ -83,8 +91,18 @@ BOOL CD2AddGemsForm::OnInitDialog()
{
__super::OnInitDialog();

// Fill in to from combo
bool isPotionSelected = false;
// Fill in from combo
bool isBeltable = false;
bool mustBeBeltable = false;
if (ItemsFormPtr != nullptr)
{
auto itemLocation = static_cast<d2ce::EnumItemLocation>(ItemsFormPtr->CurrItemLocation[0]);
if (itemLocation == d2ce::EnumItemLocation::BELT)
{
mustBeBeltable = true;
}
}

CComboBox* pFromCombo = (CComboBox*)GetDlgItem(IDC_FROM_COMBO);
if (pFromCombo != nullptr)
{
Expand All @@ -94,13 +112,15 @@ BOOL CD2AddGemsForm::OnInitDialog()
std::array<std::uint8_t, 4> selectedGemCode;
if (ItemPtr->getItemCode(selectedGemCode))
{
selectedItemData = *reinterpret_cast<std::uint32_t*>(selectedGemCode.data());
isPotionSelected = ItemPtr->isPotion();
if (!mustBeBeltable || ItemPtr->isBeltable())
{
selectedItemData = *reinterpret_cast<std::uint32_t*>(selectedGemCode.data());
}
}

}
int selectedIdx = 0;

bool hasSelectedBeltable = false;
int selectedIdx = 0;
std::array< std::uint8_t, 4> gemCode = { 0x20, 0x20, 0x20, 0x20 };
std::uint32_t& itemData = *reinterpret_cast<std::uint32_t*>(gemCode.data());
std::vector<std::string> gpsCodes;
Expand All @@ -121,6 +141,20 @@ BOOL CD2AddGemsForm::OnInitDialog()
if (itemData == selectedItemData)
{
selectedIdx = insertedIdx;
isBeltable = IsBeltableFromCode(gemCode);
}
else if (mustBeBeltable && !hasSelectedBeltable)
{
if (IsBeltableFromCode(gemCode))
{
hasSelectedBeltable = true;
selectedIdx = insertedIdx;
isBeltable = true;
}
}
else if (insertedIdx == selectedIdx)
{
isBeltable = IsBeltableFromCode(gemCode);
}
}

Expand All @@ -134,7 +168,7 @@ BOOL CD2AddGemsForm::OnInitDialog()
if (SharedStashFormPtr != nullptr)
{
CString str;
str.Format(_T("Shared Stash %ld"), SharedStashFormPtr->getCurrentPage() + 1);
str.Format(_T("Shared Stash %ld"), (int)SharedStashFormPtr->getCurrentPage() + 1);
auto insertedIdx = pLocationCombo->AddString(str);
pLocationCombo->SetItemData(insertedIdx, std::uint64_t(SharedStashFormPtr->getCurrentPage()));
pLocationCombo->SetCurSel(0);
Expand All @@ -149,9 +183,12 @@ BOOL CD2AddGemsForm::OnInitDialog()
std::uint16_t selectedItemData = 0;
if (ItemsFormPtr != nullptr)
{
selectedItemData = *reinterpret_cast<std::uint16_t*>(ItemsFormPtr->CurrItemLocation.data());
if (!mustBeBeltable || isBeltable)
{
selectedItemData = *reinterpret_cast<std::uint16_t*>(ItemsFormPtr->CurrItemLocation.data());
}
}
int selectedIdx = isPotionSelected ? 0 : 1;
int selectedIdx = isBeltable ? 0 : 1;

locationID = static_cast<std::underlying_type_t<d2ce::EnumItemLocation>>(d2ce::EnumItemLocation::BELT);
altLocationId = static_cast<std::underlying_type_t<d2ce::EnumAltItemLocation>>(d2ce::EnumAltItemLocation::UNKNOWN);
Expand Down Expand Up @@ -226,7 +263,7 @@ void CD2AddGemsForm::OnBnClickedAdd()
CString temp;
pFromCombo->GetLBText(fromIdx, temp);
msg += temp;
msg += _T(" was added to ");
msg += _T(" could not be added to ");
pLocationCombo->GetLBText(toIdx, temp);
msg += temp;
AfxMessageBox(msg, MB_ICONINFORMATION | MB_OK);
Expand All @@ -248,10 +285,10 @@ void CD2AddGemsForm::OnBnClickedAdd()
CString temp;
pFromCombo->GetLBText(fromIdx, temp);
msg += temp;
msg += _T(" was added to ");
msg += _T(" could not be added to ");
pLocationCombo->GetLBText(toIdx, temp);
msg += temp;
AfxMessageBox(msg, MB_ICONINFORMATION | MB_OK);
AfxMessageBox(msg, MB_ICONEXCLAMATION | MB_OK);
}
}
else if (!MainForm.addItem(static_cast<d2ce::EnumItemLocation>(locationID), static_cast<d2ce::EnumAltItemLocation>(altLocationId), gemCode))
Expand Down
25 changes: 24 additions & 1 deletion source/D2Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
Revision History
================
Version 2.15 (April 26, 2022)
- Updated: Reorganize resources and add txt file to allow for
future localization and customizations.
- Updated: Create GPS Dialog now chooses a beltable item by
default when launched from the belt inventory.
- Updated: Fixed some bugs related to item tooltip strings
- Updated: Fixed bugs retrieving skill names for magical
attributes for non-character specific skills
- Updated: Fixed D2R items with realm GUID. D2R now stores
128 bits instead of the 96 bits for realm GUID
- Updated: Properly calculate the displayed requirements
for items. (level, dexterity and Strength)
- Updated: Fixed player name reading for PTR2.4 and allow
use of UTF-8 characters in player name
Version 2.14 (Mar 11, 2022)
- Updated: Updated jewel alternate images.
- Updated: Updated item context menus across forms showing
Expand Down Expand Up @@ -173,7 +188,7 @@ Version 2.00 (June 18, 2021)
- Updated: The original Diablo II icon with transparant backgroud is used.
- Updated: Level Requirements will show requirments using the version of
from the character file. V1.10 is assumed to have the latest
Level Requirements from Diable II 1.14b, while versions
Level Requirements from Diablo II 1.14b, while versions
1.07-1.09 will level requirements for those versions and any
version below 1.07 will show the level requirements tha
existed since 1.00. When loading the Level Requirements dialog
Expand Down Expand Up @@ -343,6 +358,8 @@ CD2EditorApp theApp;
// CD2EditorApp initialization
BOOL CD2EditorApp::InitInstance()
{
Gdiplus::GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);

// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
Expand Down Expand Up @@ -426,3 +443,9 @@ CDocument* CD2EditorApp::OpenDocumentFile(LPCTSTR lpszFileName)
return((CDocument*)1); // CWinApp::OpenDocumentFile(lpszFileName);
}
//---------------------------------------------------------------------------
int CD2EditorApp::ExitInstance()
{
Gdiplus::GdiplusShutdown(m_gdiplusToken);
return __super::ExitInstance();
}
//---------------------------------------------------------------------------
4 changes: 4 additions & 0 deletions source/D2Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ class CD2EditorApp : public CWinAppEx

protected:
HACCEL m_haccel = NULL;

Gdiplus::GdiplusStartupInput m_gdiplusStartupInput;
ULONG_PTR m_gdiplusToken = 0;
public:
virtual BOOL ProcessMessageFilter(int code, LPMSG lpMsg);
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
virtual int ExitInstance();
};
//---------------------------------------------------------------------------
extern CD2EditorApp theApp;
Expand Down
Binary file modified source/D2Editor.rc
Binary file not shown.
Loading

0 comments on commit a6af080

Please sign in to comment.