Skip to content

Commit

Permalink
Add Runeword Dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterCouto committed Jun 5, 2022
1 parent 1edb87d commit 4167db6
Show file tree
Hide file tree
Showing 54 changed files with 2,461 additions and 586 deletions.
Binary file modified D2Editor.exe
Binary file not shown.
337 changes: 266 additions & 71 deletions d2s_File_Format.md

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Diablo II Character Editor
# Diablo II Character Editor
Copyright (c) 2000-2003 By Burton Tsang<br>
Copyright (c) 2021-2022 By Walter Couto<br>

Expand Down Expand Up @@ -77,7 +77,7 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE<br>
* [d2s Binary File Format](d2s_File_Format.md)<br>

### Revision History
**Version 2.16 (May 20, 2022)**
**Version 2.16 (June 5, 2022)**
- Updated: fix up mercenary for PTR 2.4 changes to Barbarian<br>
- Updated: reorganized item context menu<br>
- Updated: fixed "reload" issue with mercenary data that would not read the items.<br>
Expand All @@ -87,6 +87,8 @@ Check the following site for updates at https://github.com/WalterCouto/D2CE<br>
- Added: add support for dragging and dropping items.<br>
- Added: add d2i item files and support for import/export of items. The application supports the standard d2i files that exists today but if the item being exported is a D2R PTR 2.4 ear or personalized item that contains utf-8 characters outside the ASCII range, it will export the d2i file as a v1.16 item which is not the same as the format of existing d2i files.<br>
- Added: add ability to socket and unsocket items<br>
- Added: add ability to convert character file to a different version via the "Change Version" menu item.<br>
- Added: add ability to apply runewords to item via the "Apply Runeword" context menu item.<br>
<br>

**Version 2.15 (April 26, 2022)**
Expand Down
4 changes: 3 additions & 1 deletion source/D2Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Revision History
================
Version 2.16 (May 24, 2022)
Version 2.16 (June 5, 2022)
- Updated: fix up mercenary for PTR 2.4 changes to Barbarian
- Updated: reorganized item context menu
- Updated: fixed "reload" issue with mercenary data that would
Expand All @@ -38,6 +38,8 @@ Version 2.16 (May 24, 2022)
- Added: add ability to socket and unsocket items
- Added: add ability to convert character file to a different
version via the "Change Version" menu item.
- Added: add ability to apply runewords to item via the
"Apply Runeword" context menu item.
Version 2.15 (April 26, 2022)
- Updated: Reorganize resources and add txt file to allow for
Expand Down
Binary file modified source/D2Editor.rc
Binary file not shown.
6 changes: 5 additions & 1 deletion source/D2Editor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@
<ClInclude Include="D2LevelInfoForm.h" />
<ClInclude Include="D2MainForm.h" />
<ClInclude Include="D2MercenaryForm.h" />
<ClInclude Include="D2MultiLineListCtrl.h" />
<ClInclude Include="D2QuestsForm.h" />
<ClInclude Include="D2RunewordForm.h" />
<ClInclude Include="D2SharedStashForm.h" />
<ClInclude Include="D2SkillTreeForm.h" />
<ClInclude Include="D2WaypointsForm.h" />
Expand All @@ -258,7 +260,7 @@
<ClInclude Include="framework.h" />
<ClInclude Include="d2ce\Item.h" />
<ClInclude Include="d2ce\ItemConstants.h" />
<ClInclude Include="MainFormConstants.h" />
<ClInclude Include="D2MainFormConstants.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="d2ce\SkillConstants.h" />
Expand Down Expand Up @@ -332,7 +334,9 @@
<ClCompile Include="D2LevelInfoForm.cpp" />
<ClCompile Include="D2MainForm.cpp" />
<ClCompile Include="D2MercenaryForm.cpp" />
<ClCompile Include="D2MultiLineListCtrl.cpp" />
<ClCompile Include="D2QuestsForm.cpp" />
<ClCompile Include="D2RunewordForm.cpp" />
<ClCompile Include="D2SharedStashForm.cpp" />
<ClCompile Include="D2SkillTreeForm.cpp" />
<ClCompile Include="D2WaypointsForm.cpp" />
Expand Down
14 changes: 13 additions & 1 deletion source/D2Editor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MainFormConstants.h">
<ClInclude Include="D2MainFormConstants.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="D2LevelInfoForm.h">
Expand Down Expand Up @@ -291,6 +291,12 @@
<ClInclude Include="d2ce\helpers\DefaultTxtReader.h">
<Filter>Header Files\d2ce\Helpers</Filter>
</ClInclude>
<ClInclude Include="D2MultiLineListCtrl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="D2RunewordForm.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="D2Editor.cpp">
Expand Down Expand Up @@ -464,6 +470,12 @@
<ClCompile Include="d2ce\helpers\LevelsJson.cpp">
<Filter>Source Files\d2ce\Helpers</Filter>
</ClCompile>
<ClCompile Include="D2MultiLineListCtrl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="D2RunewordForm.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="D2Editor.rc">
Expand Down
44 changes: 39 additions & 5 deletions source/D2ItemsForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "D2AddGemsForm.h"
#include "D2MercenaryForm.h"
#include "D2SharedStashForm.h"
#include "D2RunewordForm.h"
#include "d2ce/helpers/ItemHelpers.h"
#include <deque>
#include <utf8/utf8.h>
Expand Down Expand Up @@ -3470,6 +3471,28 @@ d2ce::ItemFilter CD2ItemsForm::GetCurrItemFilter() const
return filter;
}
//---------------------------------------------------------------------------
bool CD2ItemsForm::setItemRuneword(d2ce::Item& item, std::uint16_t id)
{
auto preLocationId = item.getLocation();
auto preAltPositionId = item.getAltPositionId();
auto preEquipId = item.getEquippedId();
if (MainForm.setItemRuneword(item, id))
{
if (preEquipId != d2ce::EnumEquippedId::NONE)
{
refreshEquipped(preEquipId);
}
else
{
refreshGrid(preLocationId, preAltPositionId);
}

return true;
}

return false;
}
//---------------------------------------------------------------------------
const d2ce::Item* CD2ItemsForm::GetInvItem(UINT id, UINT offset) const
{
// Make sure we have hit an item
Expand Down Expand Up @@ -4190,11 +4213,6 @@ void CD2ItemsForm::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
auto filter(GetCurrItemFilter());
if (CurrItem == nullptr)
{
if (filter.LocationId == d2ce::EnumItemLocation::EQUIPPED)
{
return;
}

CMenu menu;
VERIFY(menu.LoadMenu(IDR_ITEM_MENU));

Expand Down Expand Up @@ -4225,6 +4243,14 @@ void CD2ItemsForm::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
}
}
}
else if (filter.LocationId == d2ce::EnumItemLocation::EQUIPPED)
{
auto pos = FindPopupPosition(*pPopup, ID_ITEM_CONTEXT_GPS_CREATOR);
if (pos >= 0)
{
pPopup->RemoveMenu(pos, MF_BYPOSITION);
}
}

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
return;
Expand Down Expand Up @@ -4839,6 +4865,14 @@ void CD2ItemsForm::OnItemContextRemovePersonalization()
//---------------------------------------------------------------------------
void CD2ItemsForm::OnItemContextApplyruneword()
{
if (CurrItem == nullptr)
{
return;
}

CD2RunewordForm dlg(*this);
dlg.DoModal();
SetFocus();
}
//---------------------------------------------------------------------------
void CD2ItemsForm::OnItemContextImportitem()
Expand Down
3 changes: 3 additions & 0 deletions source/D2ItemsForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class CD2ItemsForm : public CDialogEx, public CD2ItemToolTipCtrlCallback, public
friend class CD2GemsForm;
friend class CD2AddGemsForm;
friend class CD2SharedStashForm;
friend class CD2RunewordForm;
DECLARE_DYNAMIC(CD2ItemsForm)

public:
Expand Down Expand Up @@ -351,6 +352,8 @@ class CD2ItemsForm : public CDialogEx, public CD2ItemToolTipCtrlCallback, public

d2ce::ItemFilter GetCurrItemFilter() const;

bool setItemRuneword(d2ce::Item& item, std::uint16_t id);

// Inherited via CD2ItemToolTipCtrlCallback
const d2ce::Item* GetInvItem(UINT id, UINT offset) const override;
const d2ce::Item* InvHitTest(UINT id, CPoint point, TOOLINFO* pTI = nullptr) const override;
Expand Down
2 changes: 1 addition & 1 deletion source/D2LevelInfoForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ CD2LevelInfoForm::~CD2LevelInfoForm()
//---------------------------------------------------------------------------
void CD2LevelInfoForm::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
__super::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LEVELINFO_GRID, LevelInfoGrid);
}
//---------------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions source/D2MainForm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5670,6 +5670,18 @@ bool CD2MainForm::setItemLocation(d2ce::Item& item, d2ce::EnumEquippedId equippe
return false;
}
//---------------------------------------------------------------------------
bool CD2MainForm::setItemRuneword(d2ce::Item& item, std::uint16_t id)
{
if (CharInfo.setItemRuneword(item, id))
{
ItemsChanged = true;
StatsChanged();
return true;
}

return false;
}
//---------------------------------------------------------------------------
size_t CD2MainForm::getNumberOfEquippedItems() const
{
return CharInfo.getNumberOfEquippedItems();
Expand Down
4 changes: 3 additions & 1 deletion source/D2MainForm.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#pragma once

#include "d2ce/Character.h"
#include "MainFormConstants.h"
#include "D2MainFormConstants.h"
#include "resource.h"
#include <memory>
#include <set>
Expand Down Expand Up @@ -439,6 +439,8 @@ class CD2MainForm : public CDialogEx
bool setItemLocation(d2ce::Item& item, d2ce::EnumAltItemLocation altPositionId, std::uint16_t positionX, std::uint16_t positionY, d2ce::EnumItemInventory invType, const d2ce::Item*& pRemovedItem);
bool setItemLocation(d2ce::Item& item, d2ce::EnumEquippedId equippedId, d2ce::EnumItemInventory invType, const d2ce::Item*& pRemovedItem);

bool setItemRuneword(d2ce::Item& item, std::uint16_t id);

size_t getNumberOfEquippedItems() const;
const std::vector<std::reference_wrapper<d2ce::Item>>& getEquippedItems() const;

Expand Down
70 changes: 35 additions & 35 deletions source/MainFormConstants.h → source/D2MainFormConstants.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
/*
Diablo II Character Editor
Copyright (C) 2021-2022 Walter Couto
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------

#pragma once

#include "d2ce/Constants.h"
#include "d2ce/ExperienceConstants.h"
#include "d2ce/CharacterStatsConstants.h"

constexpr COLORREF EDITED_COLOUR = 0x00FFFF00;
const COLORREF NORMAL_COLOUR = GetSysColor(COLOR_WINDOW);

constexpr std::uint32_t NORMAL = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Normal);
constexpr std::uint32_t NIGHTMARE = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Nightmare);
constexpr std::uint32_t HELL = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Hell);

static const CString SettingsSection("Settings");
static const CString BackupCharacterOption("Backup Character");
//---------------------------------------------------------------------------
/*
Diablo II Character Editor
Copyright (C) 2021-2022 Walter Couto
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------

#pragma once

#include "d2ce/Constants.h"
#include "d2ce/ExperienceConstants.h"
#include "d2ce/CharacterStatsConstants.h"

constexpr COLORREF EDITED_COLOUR = 0x00FFFF00;
const COLORREF NORMAL_COLOUR = GetSysColor(COLOR_WINDOW);

constexpr std::uint32_t NORMAL = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Normal);
constexpr std::uint32_t NIGHTMARE = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Nightmare);
constexpr std::uint32_t HELL = static_cast<std::underlying_type_t<d2ce::EnumDifficulty>>(d2ce::EnumDifficulty::Hell);

static const CString SettingsSection("Settings");
static const CString BackupCharacterOption("Backup Character");
//---------------------------------------------------------------------------
Loading

0 comments on commit 4167db6

Please sign in to comment.