diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 5a1f3be2..ddd7086a 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -886,6 +886,10 @@ public: void LoadExternalSettings(); void ReloadLanguageTables(); float GetOptionFloat(const char* key, float fallback); + // INLINED + bool& ItemSlotActive() { + return reinterpret_cast(this->unknown_8128[5]); + } int GetOptionInteger(const char* key, int fallback); std::string GetOptionString(const char* key, const char* fallback); GUID GetOptionGuid(const char* key, const GUID& fallback); diff --git a/Source/UI/Cooldowns/CooldownDrawing.cpp b/Source/UI/Cooldowns/CooldownDrawing.cpp index fbd90c7c..dc738681 100644 --- a/Source/UI/Cooldowns/CooldownDrawing.cpp +++ b/Source/UI/Cooldowns/CooldownDrawing.cpp @@ -17,7 +17,7 @@ namespace { // OFFSET: 0x00CA66B0 // FUNCTION: fn_20964 void CooldownDrawing::Draw( - int centerX, int centerY, int radiusX, int radiusY, CooldownState& value, int limit, int offsetX, int offsetY, const CooldownClock& clock, + int centerX, int centerY, int radiusX, int radiusY, CooldownState& value, int limit, int offsetX, int offsetY, RenderCommandPool& pool, CRenderSystemBase& system ) { if (value.x <= 0 || value.y <= 0 || (value.color & 0xFF000000u) == 0) { @@ -71,7 +71,7 @@ void CooldownDrawing::Draw( value.AddEdge(7, vertices[reversed ? 22 : 2].x, radiusX, 1); if (reversed) { - this->DrawReverse(value, clock, pool, system); + this->DrawReverse(value, pool, system); return; } @@ -81,7 +81,7 @@ void CooldownDrawing::Draw( const unsigned previous = value.segment; if (previous < 8) { - const float position = value.Update(clock); + const float position = value.Update(); RenderVertex& vertex = vertices[23 - 3 * previous]; if (previous == 0 || previous == 3 || previous == 4 || previous == 7) { vertex.x = position; @@ -109,14 +109,14 @@ void CooldownDrawing::Draw( // OFFSET: 0x00CA6C00 // FUNCTION: fn_20965 -void CooldownDrawing::DrawReverse(CooldownState& value, const CooldownClock& clock, RenderCommandPool& pool, CRenderSystemBase& system) { +void CooldownDrawing::DrawReverse(CooldownState& value, RenderCommandPool& pool, CRenderSystemBase& system) { if (value.duration == 0) { return; } const unsigned previous = value.segment; if (previous < 8) { - const float position = value.Update(clock); + const float position = value.Update(); RenderVertex& vertex = value.vertices[2 + 3 * previous]; if (previous == 0 || previous == 3 || previous == 4 || previous == 7) { vertex.x = position; diff --git a/Source/UI/Cooldowns/CooldownDrawing.h b/Source/UI/Cooldowns/CooldownDrawing.h index 1a6d2731..237dd0c0 100644 --- a/Source/UI/Cooldowns/CooldownDrawing.h +++ b/Source/UI/Cooldowns/CooldownDrawing.h @@ -15,14 +15,14 @@ struct CooldownDrawing { /* 0010 */ std::vector reverse; void Draw( - int centerX, int centerY, int radiusX, int radiusY, CooldownState& value, int limit, int offsetX, int offsetY, const CooldownClock& clock, + int centerX, int centerY, int radiusX, int radiusY, CooldownState& value, int limit, int offsetX, int offsetY, RenderCommandPool& pool, CRenderSystemBase& system ); void SubmitNormal(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); void SubmitReverse(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); private: - void DrawReverse(CooldownState& value, const CooldownClock& clock, RenderCommandPool& pool, CRenderSystemBase& system); + void DrawReverse(CooldownState& value, RenderCommandPool& pool, CRenderSystemBase& system); }; #if defined(_WIN32) && !defined(_WIN64) diff --git a/Source/UI/Cooldowns/CooldownState.cpp b/Source/UI/Cooldowns/CooldownState.cpp index 06e7a48f..04759f25 100644 --- a/Source/UI/Cooldowns/CooldownState.cpp +++ b/Source/UI/Cooldowns/CooldownState.cpp @@ -1,4 +1,5 @@ #include "UI/Cooldowns/CooldownState.h" +#include "Client/Replay.h" #include #include @@ -6,8 +7,8 @@ #include // INLINED -std::uint32_t CooldownClock::Now() const { - return this->restricted ? this->serverTick : timeGetTime(); +std::uint32_t CooldownNow() { + return g_replayAnimationScaling ? Replay::Instance().elapsed : timeGetTime(); } // OFFSET: 0x00CA4F30 @@ -45,14 +46,14 @@ void CooldownState::AddEdge(unsigned key, float origin, int radius, unsigned cha // OFFSET: 0x00CA5180 // FUNCTION: fn_20948 -float CooldownState::Update(const CooldownClock& clock) { - std::uint32_t progress = clock.Now() + this->elapsed - this->start; +float CooldownState::Update() { + std::uint32_t progress = CooldownNow() + this->elapsed - this->start; if (this->duration - progress <= 60000 && this->finalMinute == 0 && this->reverse == 1) { const std::uint32_t previous = this->duration; this->finalMinute = 1; this->duration = 60000; this->elapsed = progress - previous + 60000; - this->start = clock.Now(); + this->start = CooldownNow(); this->angle = 0; this->color = 0xAAFF6633u; progress = this->elapsed; diff --git a/Source/UI/Cooldowns/CooldownState.h b/Source/UI/Cooldowns/CooldownState.h index 30035ce9..cfd179b1 100644 --- a/Source/UI/Cooldowns/CooldownState.h +++ b/Source/UI/Cooldowns/CooldownState.h @@ -13,11 +13,7 @@ struct CooldownEdge { /* 000C */ unsigned char increasing; }; -struct CooldownClock { - const bool& restricted; - const std::uint32_t& serverTick; - std::uint32_t Now() const; -}; +std::uint32_t CooldownNow(); struct CooldownState { /* 0000 */ std::map edges; @@ -40,7 +36,7 @@ struct CooldownState { ~CooldownState(); void ClearEdges(); void AddEdge(unsigned segment, float origin, int radius, unsigned char increasing); - float Update(const CooldownClock& clock); + float Update(); }; static_assert(sizeof(CooldownEdge) == 16); diff --git a/Source/UI/Shortcuts/ShortcutControlEvents.h b/Source/UI/Shortcuts/ShortcutControlEvents.h deleted file mode 100644 index 1d35d8ec..00000000 --- a/Source/UI/Shortcuts/ShortcutControlEvents.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTCONTROLEVENTS_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTCONTROLEVENTS_H - -#include "UI/Shortcuts/ShortcutControls.h" -#include "UI/Shortcuts/ShortcutGrid.h" - -class UIWindow; -struct ShortcutCooldowns; - -struct ShortcutControlEvents { - UIWindow& window; - ShortcutGrid& grid; - ShortcutControls& controls; - ShortcutCooldowns& cooldowns; - bool& itemSlotActive; - - void Click(int id); -}; - -#endif diff --git a/Source/UI/Shortcuts/ShortcutCooldowns.cpp b/Source/UI/Shortcuts/ShortcutCooldowns.cpp index 0ed2c97f..817fa99b 100644 --- a/Source/UI/Shortcuts/ShortcutCooldowns.cpp +++ b/Source/UI/Shortcuts/ShortcutCooldowns.cpp @@ -12,6 +12,7 @@ #include "UI/Buttons/UIButton.h" #include "UI/Shop/ItemDrawing.h" #include "UI/Shortcuts/UIQuickSlotWnd.h" +#include "UI/Cooldowns/CooldownOwner.h" #include "UI/Window/UIRebirthWnd.h" #include "UI/Window/UISeekPartyMBWnd.h" #include "UI/Window/UISeekPartyWnd.h" @@ -176,7 +177,7 @@ void ShortcutCooldowns::ApplyStart( } // INLINED -bool ShortcutCooldowns::RotateRows(int amount, int bank, int& rotation0, int& rotation1, const CooldownClock& clock) { +bool ShortcutCooldowns::RotateRows(int amount, int bank, int& rotation0, int& rotation1) { const int rows = amount < 4 ? amount : amount % 4; if (rows <= 0) { return false; @@ -190,7 +191,7 @@ bool ShortcutCooldowns::RotateRows(int amount, int bank, int& rotation0, int& ro } } - const std::uint32_t now = clock.Now(); + const std::uint32_t now = CooldownNow(); for (auto entry = this->records.begin(); entry != this->records.end();) { if (entry->end <= now) { @@ -215,27 +216,26 @@ bool ShortcutCooldowns::RotateRows(int amount, int bank, int& rotation0, int& ro // INLINED void ShortcutCooldowns::PaintMain( - const std::list& icons, int rows, int x, int y, CooldownDrawing& drawing, const CooldownClock& clock, RenderCommandPool& pool, + const std::list& icons, int rows, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ) { const int limit = rows * 33 + 4; - this->Paint(icons, &ShortcutCooldownRecord::main, limit, x, y, drawing, clock, pool, system); + this->Paint(icons, &ShortcutCooldownRecord::main, limit, x, y, drawing, pool, system); } // INLINED void ShortcutCooldowns::PaintAlternate( - const std::list& icons, int x, int y, CooldownDrawing& drawing, const CooldownClock& clock, RenderCommandPool& pool, + const std::list& icons, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ) { - this->Paint(icons, &ShortcutCooldownRecord::alternate, 0, x, y, drawing, clock, pool, system); + this->Paint(icons, &ShortcutCooldownRecord::alternate, 0, x, y, drawing, pool, system); } // INLINED void ShortcutCooldowns::Paint( - const std::list& icons, std::list ShortcutCooldownRecord::* values, int limit, int x, int y, CooldownDrawing& drawing, - const CooldownClock& clock, RenderCommandPool& pool, CRenderSystemBase& system + const std::list& icons, std::list ShortcutCooldownRecord::* values, int limit, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ) { - const std::uint32_t now = clock.Now(); + const std::uint32_t now = CooldownNow(); for (auto entry = this->records.begin(); entry != this->records.end();) { if (entry->end <= now) { @@ -256,7 +256,7 @@ void ShortcutCooldowns::Paint( } for (CooldownState& state : states) { - drawing.Draw(0, 0, 12, 12, state, limit, x, y, clock, pool, system); + drawing.Draw(0, 0, 12, 12, state, limit, x, y, pool, system); } ++entry; @@ -398,14 +398,13 @@ void UISeekPartyWnd::Paint() { // OFFSET: 0x0092D660 // FUNCTION: fn_12671 void UIQuickSlotWnd::Paint() { - QuickSlotPainting& painting = *this->m_painting; this->DrawPanelBackground(0, 0, "유저인터페이스\\basic_interface\\quickslot.bmp"); if (this->m_selected != -1) { const SkinPaletteCell cell = {2, 2}; this->FillRegion(this->m_selected * 29 + 5, 5, 24, 24, SkinPaletteColor(ResourceMgr::Instance(), cell, g_skinInfo.Selected())); } - painting.icons.clear(); + g_session.m_alternateCooldownIcons.clear(); for (int index = 0; index < 2; ++index) { const QuickSlotEntry& entry = this->m_entries[index]; @@ -423,7 +422,7 @@ void UIQuickSlotWnd::Paint() { char text[1024]; std::sprintf(text, "유저인터페이스\\item\\%s.bmp", skill.name); auto* image = static_cast(ResourceMgr::Instance().Load(Resolve(text))); - painting.icons.push_back({skill.id, index, x, 5}); + g_session.m_alternateCooldownIcons.push_back({skill.id, index, x, 5}); this->DrawBitmap(x, 5, &image->image, true); if (entry.count != 0) { std::sprintf(text, "%d", entry.count); @@ -434,7 +433,7 @@ void UIQuickSlotWnd::Paint() { this->DrawTextAt(x + 14, 20, text, 0, 0, 11, 0, 0, 0); } } else { - ITEM_INFO item = LookupClientItem(painting.inventory, static_cast(entry.id), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(entry.id), 1); if (item.unknown_0000[1] == 0) { continue; } @@ -448,7 +447,7 @@ void UIQuickSlotWnd::Paint() { } } - painting.cooldowns.PaintAlternate(painting.icons, this->geometry.x, this->geometry.y, painting.drawing, painting.clock, painting.commands, painting.system); + reinterpret_cast(g_session.m_requestTimers).PaintAlternate(g_session.m_alternateCooldownIcons, this->geometry.x, this->geometry.y, g_cooldownOwner->Drawing(), this->m_painting->commands, this->m_painting->system); } // OFFSET: 0x00924A50 @@ -471,7 +470,7 @@ void UIQuickSlotWnd::Slot26(int x, int y) { return; } - AutomaticSkills& automatic = this->m_painting->automatic; + AutomaticSkills& automatic = *reinterpret_cast(g_session.unknown_7FB4); const QuickSlotEntry& entry = this->m_entries[slot]; if (entry.skill && automatic.Contains(static_cast(entry.id))) { g_session.SetOption(AutomaticSkills::CancelOption(static_cast(entry.id)), 1, 0); diff --git a/Source/UI/Shortcuts/ShortcutCooldowns.h b/Source/UI/Shortcuts/ShortcutCooldowns.h index 8d9da843..e7d75b15 100644 --- a/Source/UI/Shortcuts/ShortcutCooldowns.h +++ b/Source/UI/Shortcuts/ShortcutCooldowns.h @@ -33,21 +33,20 @@ struct ShortcutCooldowns { const std::uint32_t& serverTick ); void LoadRecords(const void* packet); - bool RotateRows(int amount, int bank, int& rotation0, int& rotation1, const CooldownClock& clock); + bool RotateRows(int amount, int bank, int& rotation0, int& rotation1); void PaintMain( - const std::list& icons, int rows, int x, int y, CooldownDrawing& drawing, const CooldownClock& clock, RenderCommandPool& pool, + const std::list& icons, int rows, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ); void PaintAlternate( - const std::list& icons, int x, int y, CooldownDrawing& drawing, const CooldownClock& clock, RenderCommandPool& pool, + const std::list& icons, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ); private: void Paint( - const std::list& icons, std::list ShortcutCooldownRecord::* values, int limit, int x, int y, CooldownDrawing& drawing, - const CooldownClock& clock, RenderCommandPool& pool, CRenderSystemBase& system + const std::list& icons, std::list ShortcutCooldownRecord::* values, int limit, int x, int y, CooldownDrawing& drawing, RenderCommandPool& pool, CRenderSystemBase& system ); }; diff --git a/Source/UI/Shortcuts/ShortcutDetails.cpp b/Source/UI/Shortcuts/ShortcutDetails.cpp index 118c8e7f..65728e81 100644 --- a/Source/UI/Shortcuts/ShortcutDetails.cpp +++ b/Source/UI/Shortcuts/ShortcutDetails.cpp @@ -1,13 +1,14 @@ #include "Client/Session.h" -#include "UI/Shortcuts/ShortcutDetails.h" -#include "UI/Shortcuts/SkillDetailClose.h" +#include "UI/Shortcuts/UIShortCutWnd.h" +#include "UI/Skill/UISkillDescribeWnd.h" +#include "Render/DX7/RenderSystemDX7.h" #include "UI/Window/UIWindow.h" #include "UI/Window/WindowManagerWindows.h" #include "UI/Window/UIWindowMgr.h" namespace { // INLINED - void ToScreen(const UIWindow& window, int& x, int& y) { + void ScreenPosition(const UIWindow& window, int& x, int& y) { x = (x + window.geometry.x); y = (y + window.geometry.y); @@ -18,53 +19,25 @@ namespace { } } -// INLINED -inline bool SkillDetailClose::Close() { - if (this->window) { - this->saved[46] = {this->window->geometry.x, this->window->geometry.y, this->window->geometry.width, this->window->geometry.height}; - } - - if (!this->modalStack.empty() && this->modalStack.back() != 0) { - return false; - } - - if (this->window == this->reference_4F1D4) { - this->reference_4F1D4 = nullptr; - } - - bool removed = false; - - if (this->window) { - this->retirement.Schedule(this->window); - this->window = nullptr; - this->visible = 0; - removed = true; - } - - this->windowsById.erase(46); - - if (removed) { - g_windowMgr.RemoveOrder(46); - } - - return removed; -} - // OFFSET: 0x009332D0 // FUNCTION: fn_12724 -void ShortcutDetails::Open(UIWindow& window, ShortcutGrid& grid, int x, int y, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots) { - const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); +void UIShortCutWnd::Slot32(int x, int y) { + UIWindow& window = *this; + ShortcutGrid& grid = this->m_grid; + const NormalItemSlot* const* slots = this->m_slots; + const NormalItemSlot* const* itemSlots = this->m_itemSlots; + const int column = grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); if (column == -1) { return; } - const int index = 9 * this->currentRow + column; + const int index = 9 * g_session.m_hotkeyPage + column; const int limit = 9 * grid.rows; const NormalItemSlot* slot; if (limit <= index) { - if (!this->itemSlotActive) { + if (!g_session.ItemSlotActive()) { return; } @@ -78,10 +51,10 @@ void ShortcutDetails::Open(UIWindow& window, ShortcutGrid& grid, int x, int y, c } if (limit <= index || slot->unknown_0000 == 0) { - ITEM_INFO item = LookupClientItem(this->inventory, static_cast(slot->itemId), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(slot->itemId), 1); if (item.unknown_0000[1] != 0) { - UIWindow* detail = this->windows.EnsureWindow(12); + UIWindow* detail = g_windowMgr.EnsureWindow(12); detail->SendMsg(nullptr, 24, reinterpret_cast(&item), 0, 0, 0); } @@ -94,11 +67,11 @@ void ShortcutDetails::Open(UIWindow& window, ShortcutGrid& grid, int x, int y, c return; } - UIWindow* detail = this->windows.EnsureWindow(46); + UIWindow* detail = g_windowMgr.EnsureWindow(46); if (detail) { - if (this->describedSkill == skill.id) { - this->skillClose.Close(); + if (static_cast(static_cast(detail)->m_skillId) == skill.id) { + g_windowMgr.CloseWindow(46); } else { detail->SendMsg(nullptr, 61, skill.id, 0, 0, 0); } @@ -106,17 +79,17 @@ void ShortcutDetails::Open(UIWindow& window, ShortcutGrid& grid, int x, int y, c int originX = 0; int originY = 0; - ToScreen(window, originX, originY); + ScreenPosition(window, originX, originY); const int targetX = (originX + x); int adjustment = 0; - if (this->screenWidth - static_cast(targetX) < static_cast(detail->geometry.width)) { - adjustment = targetX + detail->geometry.width - static_cast(this->screenWidth); + if (static_cast(g_configuredScreenWidth) - static_cast(targetX) < static_cast(detail->geometry.width)) { + adjustment = targetX + detail->geometry.width - static_cast(static_cast(g_configuredScreenWidth)); } const int rowY = 33 * (y / 33); const int targetY = - static_cast(originY) <= static_cast(this->screenHeight) * 0.5f ? ((originY + rowY) + 33) : ((originY + rowY) - detail->geometry.height); + static_cast(originY) <= static_cast(static_cast(g_configuredScreenHeight)) * 0.5f ? ((originY + rowY) + 33) : ((originY + rowY) - detail->geometry.height); detail->Move(targetX - adjustment, targetY); } diff --git a/Source/UI/Shortcuts/ShortcutDetails.h b/Source/UI/Shortcuts/ShortcutDetails.h deleted file mode 100644 index 91747d00..00000000 --- a/Source/UI/Shortcuts/ShortcutDetails.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTDETAILS_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTDETAILS_H - -#include "Contents/Skills/ClientSkills.h" -#include "Contents/Items/ItemInfo.h" -#include "Contents/UserData/NormalItemSlots.h" -#include "UI/Shortcuts/ShortcutGrid.h" - -class UIWindow; -#include "UI/Window/WindowManagerWindows.h" -struct SkillDetailClose; - -struct ShortcutDetails { - WindowManagerWindows& windows; - SkillDetailClose& skillClose; - const std::uint32_t& describedSkill; - const std::list& inventory; - const bool& itemSlotActive; - unsigned char& currentRow; - const unsigned& screenWidth; - const unsigned& screenHeight; - - void Open(UIWindow& window, ShortcutGrid& grid, int x, int y, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots); -}; - -#endif diff --git a/Source/UI/Shortcuts/ShortcutDrop.cpp b/Source/UI/Shortcuts/ShortcutDrop.cpp index 63a05271..6168423a 100644 --- a/Source/UI/Shortcuts/ShortcutDrop.cpp +++ b/Source/UI/Shortcuts/ShortcutDrop.cpp @@ -4,7 +4,7 @@ #include "Client/Session.h" #include "Contents/Skills/ClientSkills.h" #include "UI/Shortcuts/UIQuickSlotWnd.h" -#include "UI/Shortcuts/ShortcutDrop.h" +#include "UI/Shortcuts/UIShortCutWnd.h" #include "UI/Window/UINewSelectCharWnd.h" #include "UI/Window/UIWindow.h" #include @@ -38,26 +38,30 @@ namespace { // OFFSET: 0x00917640 // FUNCTION: fn_12589 -void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, const ModeDragState& value) { +void UIShortCutWnd::Slot10(int x, int y, std::intptr_t argument) { + UIWindow& window = *this; + ShortcutGrid& grid = this->m_grid; + const ModeDragState& value = *reinterpret_cast(argument); + CMode* mode = static_cast(g_charViewMode); const int bank = g_session.unknown_06FC; if (value.skill != 0) { const std::string copiedName = value.skillName; const std::uint32_t id = value.id; - const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); - const int index = 9 * this->currentRow + column; + const int column = grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); + const int index = 9 * g_session.m_hotkeyPage + column; const int originalSlot = value.slot; if (column != -1) { if (index == originalSlot) { - this->mode->SendModeMessage(18, 0, 0, 0, 0); + mode->SendMsg(18, 0, 0, 0, 0); return; } CSkillInfo skill = g_session.LookupSkill(id); - if ((skill.level == 0 && skill.available == 0) || grid.rows <= this->currentRow) { - if (this->mode) { - this->mode->SendModeMessage(18, 0, 0, 0, 0); + if ((skill.level == 0 && skill.available == 0) || grid.rows <= g_session.m_hotkeyPage) { + if (mode) { + mode->SendMsg(18, 0, 0, 0, 0); } return; @@ -79,7 +83,7 @@ void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, cons if (record != reinterpret_cast(g_session.m_requestTimers).records.end() && record->end > timeGetTime()) { const auto previous = std::find_if(record->main.begin(), record->main.end(), [&](const CooldownState& state) { return state.slot == originalSlot; }); const int targetX = 29 * column + 16; - const int targetY = 33 * this->currentRow + 4; + const int targetY = 33 * g_session.m_hotkeyPage + 4; if (previous != record->main.end() && previous->y == targetY) { previous->slot = index; @@ -109,18 +113,18 @@ void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, cons Refresh(window); } - this->mode->SendModeMessage(18, 0, 0, 0, 0); + mode->SendMsg(18, 0, 0, 0, 0); return; } if (value.source == 6 || value.source == 9) { - this->mode->SendModeMessage(18, 0, 0, 0, 0); + mode->SendMsg(18, 0, 0, 0, 0); return; } - ITEM_INFO item = LookupClientItemByIdentity(this->inventory, value.id); + ITEM_INFO item = LookupClientItemByIdentity(g_session.m_inventoryItems, value.id); if (item.unknown_0000[1] == 0 || item.identified == 0) { - this->mode->SendModeMessage(18, 0, 0, 0, 0); + mode->SendMsg(18, 0, 0, 0, 0); return; } @@ -128,9 +132,9 @@ void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, cons bool consumed = false; if (type == 3 || type == 10 || type == 16 || type == 17 || type == 19) { - const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); - if (column != -1 && 9 * grid.rows <= 9 * this->currentRow + column) { - if (this->itemSlotActive) { + const int column = grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); + if (column != -1 && 9 * grid.rows <= 9 * g_session.m_hotkeyPage + column) { + if (g_session.ItemSlotActive()) { g_session.AssignItemShortcut(static_cast(item.GetItemId()), column); Refresh(window); } @@ -146,9 +150,9 @@ void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, cons } if (allowed) { - const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); - if (column != -1 && grid.rows > this->currentRow) { - const int index = 9 * this->currentRow + column; + const int column = grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); + if (column != -1 && grid.rows > g_session.m_hotkeyPage) { + const int index = 9 * g_session.m_hotkeyPage + column; g_session.AssignShortcut(0, static_cast(item.GetItemId()), 0, index, bank); if (value.slot != index) { RemoveFirst(reinterpret_cast(g_session.m_requestTimers), index); @@ -159,7 +163,7 @@ void ShortcutDrop::Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, cons } } - this->mode->SendModeMessage(18, 0, 0, 0, 0); + mode->SendMsg(18, 0, 0, 0, 0); } namespace { @@ -183,9 +187,8 @@ namespace { // OFFSET: 0x00917100 // FUNCTION: fn_12588 void UIQuickSlotWnd::Slot10(int x, int y, std::intptr_t argument) { - QuickSlotPainting& painting = *this->m_painting; const ModeDragState& value = *reinterpret_cast(argument); - std::list& records = painting.cooldowns.records; + std::list& records = reinterpret_cast(g_session.m_requestTimers).records; if (value.skill != 0) { const std::string copiedName(value.skillName.c_str(), value.skillName.size()); @@ -194,7 +197,7 @@ void UIQuickSlotWnd::Slot10(int x, int y, std::intptr_t argument) { CSkillInfo skill = g_session.LookupSkill(value.id); if (skill.level != 0 && skill.available != 0) { g_session.SetHotkeyEntry(1, skill.id, value.skillLevel, slot); - RemoveAlternate(painting.cooldowns, value.slot, slot); + RemoveAlternate(reinterpret_cast(g_session.m_requestTimers), value.slot, slot); const std::uint32_t key = Grouped(skill.id) ? 9999 : skill.id; const std::list::iterator record = @@ -238,7 +241,7 @@ void UIQuickSlotWnd::Slot10(int x, int y, std::intptr_t argument) { this->Invalidate(); } } else if (value.source != 6 && value.source != 9) { - ITEM_INFO item = LookupClientItemByIdentity(painting.inventory, value.id); + ITEM_INFO item = LookupClientItemByIdentity(g_session.m_inventoryItems, value.id); if (item.unknown_0000[1] != 0 && item.identified != 0) { switch (item.unknown_0000[0]) { case 4: @@ -263,7 +266,7 @@ void UIQuickSlotWnd::Slot10(int x, int y, std::intptr_t argument) { const int slot = this->SlotAt(x, y); if (slot != -1) { g_session.SetHotkeyEntry(0, item.GetItemId(), 0, slot); - RemoveAlternate(painting.cooldowns, value.slot, slot); + RemoveAlternate(reinterpret_cast(g_session.m_requestTimers), value.slot, slot); this->SendMsg(nullptr, 23, 0, 0, 0, 0); this->Invalidate(); } diff --git a/Source/UI/Shortcuts/ShortcutDrop.h b/Source/UI/Shortcuts/ShortcutDrop.h deleted file mode 100644 index 95063b4c..00000000 --- a/Source/UI/Shortcuts/ShortcutDrop.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTDROP_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTDROP_H - -#include "Contents/Items/ItemInfo.h" -#include "Script/LuaScript.h" -#include "Client/Mode/ModeEvents.h" -#include "UI/Shortcuts/ShortcutGrid.h" - -class UIWindow; -struct ModeDragState; - -struct ShortcutDrop { - LuaScript& script; - ModeEvents*& mode; - const std::list& inventory; - const bool& itemSlotActive; - unsigned char& currentRow; - - void Drop(UIWindow& window, ShortcutGrid& grid, int x, int y, const ModeDragState& value); -}; - -#endif diff --git a/Source/UI/Shortcuts/ShortcutLayout.h b/Source/UI/Shortcuts/ShortcutLayout.h deleted file mode 100644 index 476c5a50..00000000 --- a/Source/UI/Shortcuts/ShortcutLayout.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTLAYOUT_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTLAYOUT_H - -#include "Contents/UserData/NormalItemSlots.h" -#include "UI/Shortcuts/ShortcutGrid.h" - -class UIWindow; -class UIBitmapButton; - -struct ShortcutLayout { - UIWindow& window; - ShortcutGrid& grid; - NormalItemSlotWindow*& saved; - UIBitmapButton& decrease; - UIBitmapButton& increase; - UIBitmapButton& showItems; - UIBitmapButton& hideItems; - const bool& itemSlotActive; - const int& screenWidth; - const int& screenHeight; - - void ResizeRows(); - void Restore(NormalItemSlotWindow* value); - void Persist(); - -private: - void PlaceRowButtons(); -}; - -#endif diff --git a/Source/UI/Shortcuts/ShortcutPainting.cpp b/Source/UI/Shortcuts/ShortcutPainting.cpp index 00b5b9ac..f63d393d 100644 --- a/Source/UI/Shortcuts/ShortcutPainting.cpp +++ b/Source/UI/Shortcuts/ShortcutPainting.cpp @@ -4,6 +4,8 @@ #include "Resource/ResourceMgr.h" #include "UI/Shop/ItemDrawing.h" #include "UI/Shortcuts/ShortcutPainting.h" +#include "UI/Shortcuts/UIShortCutWnd.h" +#include "UI/Cooldowns/CooldownOwner.h" #include "UI/Window/UIWindow.h" #include @@ -56,29 +58,34 @@ void UIWindow::DrawRightOutlinedText( // OFFSET: 0x0092F8E0 // FUNCTION: fn_12680 -void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots) { - CBitmapRes* frame = Load(this->resources, "\\Shortcut\\shortcut_frame.bmp"); +void UIShortCutWnd::Paint() { + UIWindow& window = *this; + const ShortcutGrid& grid = this->m_grid; + const NormalItemSlot* const* slots = this->m_slots; + const NormalItemSlot* const* itemSlots = this->m_itemSlots; + ResourceMgr& resources = ResourceMgr::Instance(); + CBitmapRes* frame = Load(resources, "\\Shortcut\\shortcut_frame.bmp"); for (int row = 0; row < grid.rows; ++row) { Bitmap(window, frame, 0, (row * 33), false); } - if (this->itemSlotActive) { - Bitmap(window, Load(this->resources, "\\Shortcut\\shortcut_frame_item.bmp"), 0, grid.rows > 0 ? (grid.rows * 33) : 0, false); + if (g_session.ItemSlotActive()) { + Bitmap(window, Load(resources, "\\Shortcut\\shortcut_frame_item.bmp"), 0, grid.rows > 0 ? (grid.rows * 33) : 0, false); } if (grid.row != -1 && grid.hovered != -1) { - CBitmapRes* chip = Load(this->resources, "\\colorchip.bmp"); + CBitmapRes* chip = Load(resources, "\\colorchip.bmp"); std::uint32_t color = 0; if (chip) { const std::uint32_t pixel = chip->image.width > 10 && chip->image.height > 10 ? chip->image.pixels[10 + 10 * chip->image.width] : 0x00FF0000u; color = ((pixel & 255) << 16) | (pixel & 0xFF00) | ((pixel >> 16) & 255); } - window.FillRegion(((grid.hovered * 29) + 16), 5 + 33 * static_cast(this->currentRow), 24, 24, color); + window.FillRegion(((grid.hovered * 29) + 16), 5 + 33 * static_cast(g_session.m_hotkeyPage), 24, 24, color); } - this->icons.clear(); + g_session.m_mainCooldownIcons.clear(); for (int row = 0; row < grid.rows; ++row) { const int y = ((row * 33) + 4); @@ -104,12 +111,12 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N char path[200]; std::sprintf(path, "%s\\item\\%s.bmp", prefix, skill.name); - CBitmapRes* image = static_cast(this->resources.Load(path)); + CBitmapRes* image = static_cast(resources.Load(path)); if (!image) { - image = Load(this->resources, "\\item\\am_berserkpitcher.bmp"); + image = Load(resources, "\\item\\am_berserkpitcher.bmp"); } - this->icons.push_back({skill.id, index, x, y}); + g_session.m_mainCooldownIcons.push_back({skill.id, index, x, y}); Bitmap(window, image, x, y, true); int level = slot.unknown_0005; @@ -119,12 +126,12 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N Count(window, x + 27, (y + 17), level); } else { - ITEM_INFO item = LookupClientItem(this->inventory, static_cast(slot.itemId), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(slot.itemId), 1); if (item.unknown_0000[1] == 0) { continue; } - DrawItemIcon(window, this->resources, x, y, item, static_cast(item.unknown_0060)); + DrawItemIcon(window, resources, x, y, item, static_cast(item.unknown_0060)); if (item.quantity != 0) { Count(window, x + 27, (y + 17), item.quantity); } @@ -132,13 +139,13 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N if (item.unknown_0088 > 0) { char tail[96]; std::sprintf(tail, "\\grade_enchant\\grade_icon%d.bmp", item.unknown_0088); - Bitmap(window, Load(this->resources, tail), x, (y + 12), true); + Bitmap(window, Load(resources, tail), x, (y + 12), true); } } } } - if (this->itemSlotActive) { + if (g_session.ItemSlotActive()) { const int y = ((grid.rows * 33) + 4); for (int column = 0; column < 9; ++column) { @@ -147,13 +154,13 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N continue; } - ITEM_INFO item = LookupClientItem(this->inventory, static_cast(slot.itemId), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(slot.itemId), 1); if (item.unknown_0000[1] == 0) { continue; } const int x = 16 + 29 * column; - DrawItemIcon(window, this->resources, x, y, item, static_cast(item.unknown_0060)); + DrawItemIcon(window, resources, x, y, item, static_cast(item.unknown_0060)); if (item.quantity != 0) { Count(window, x + 27, (y + 17), item.quantity); } @@ -166,5 +173,6 @@ void ShortcutPainting::Paint(UIWindow& window, const ShortcutGrid& grid, const N window.DrawTextAt(6, ((row * 33) + 13), text, 0, 0, 11, 0x2F4A4A, 0, 0); } - this->cooldowns.PaintMain(this->icons, grid.rows, window.geometry.x, window.geometry.y, this->drawing, this->clock, this->commands, this->system); + reinterpret_cast(g_session.m_requestTimers) + .PaintMain(g_session.m_mainCooldownIcons, grid.rows, window.geometry.x, window.geometry.y, g_cooldownOwner->Drawing(), this->m_painting->commands, this->m_painting->system); } diff --git a/Source/UI/Shortcuts/ShortcutPainting.h b/Source/UI/Shortcuts/ShortcutPainting.h index ad576472..7e47cb22 100644 --- a/Source/UI/Shortcuts/ShortcutPainting.h +++ b/Source/UI/Shortcuts/ShortcutPainting.h @@ -14,20 +14,8 @@ class FontCache; struct TextLocale; struct ShortcutPainting { - ResourceMgr& resources; - FontCache& fonts; - const TextLocale& locale; - const std::list& inventory; - std::list& icons; - ShortcutCooldowns& cooldowns; - CooldownDrawing& drawing; - const CooldownClock& clock; RenderCommandPool& commands; CRenderSystemBase& system; - const bool& itemSlotActive; - const unsigned char& currentRow; - - void Paint(UIWindow& window, const ShortcutGrid& grid, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots); }; #endif diff --git a/Source/UI/Shortcuts/ShortcutPress.cpp b/Source/UI/Shortcuts/ShortcutPress.cpp index 074de768..2490c5d7 100644 --- a/Source/UI/Shortcuts/ShortcutPress.cpp +++ b/Source/UI/Shortcuts/ShortcutPress.cpp @@ -1,28 +1,36 @@ #include "Client/Session.h" #include "Client/Mode/ModeDragState.h" -#include "UI/Shortcuts/ShortcutPress.h" +#include "Client/Mode/CGameMode.h" +#include "Client/Mode/ModeMgr.h" +#include "Client/Replay.h" +#include "Resource/ResourceMgr.h" +#include "UI/Shortcuts/UIShortCutWnd.h" +#include "UI/Window/UIWindowMgr.h" #include "UI/Window/UIFrameWnd.h" // OFFSET: 0x009310E0 // FUNCTION: fn_12699 -void ShortcutPress::Press(UIFrameWnd& window, ShortcutGrid& grid, int x, int y, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots) { +void UIShortCutWnd::Slot25(int x, int y) { + ShortcutGrid& grid = this->m_grid; + const NormalItemSlot* const* slots = this->m_slots; + const NormalItemSlot* const* itemSlots = this->m_itemSlots; const int columnOffset = x - 15; if (columnOffset >= 261 || x < 15 || y < 4) { - window.UIFrameWnd::Slot25(x, y); + this->UIFrameWnd::Slot25(x, y); return; } - if (this->restricted) { + if (g_replayAnimationScaling) { return; } - const int column = grid.HitTest(x, y, this->itemSlotActive, this->currentRow); + const int column = grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); if (column == -1) { return; } grid.hovered = column; - const int index = 9 * this->currentRow + column; + const int index = 9 * g_session.m_hotkeyPage + column; if (9 * grid.rows > index) { const NormalItemSlot& slot = *slots[index]; if (slot.itemId == 0) { @@ -31,24 +39,24 @@ void ShortcutPress::Press(UIFrameWnd& window, ShortcutGrid& grid, int x, int y, if (slot.unknown_0000 != 0) { CSkillInfo skill = g_session.LookupSkill(slot.itemId); - if (skill.MatchesShortcut(&slot) && this->drag) { - this->drag->BeginSkill(this->windows, this->resources, 7, skill.id, skill.name, slot.unknown_0005, index); + if (skill.MatchesShortcut(&slot) && g_modeMgr.GetGameMode()) { + static_cast(g_modeMgr.GetGameMode())->drag.BeginSkill(g_windowMgr, ResourceMgr::Instance(), 7, skill.id, skill.name, slot.unknown_0005, index); } } else { - ITEM_INFO item = LookupClientItem(this->inventory, static_cast(slot.itemId), 1); - if (item.unknown_0000[1] != 0) { - this->drag->BeginItem(this->windows, 7, item, item.quantity, -1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(slot.itemId), 1); + if (item.unknown_0000[1] != 0 && g_modeMgr.GetGameMode()) { + static_cast(g_modeMgr.GetGameMode())->drag.BeginItem(g_windowMgr, 7, item, item.quantity, -1); } } - } else if (this->itemSlotActive) { + } else if (g_session.ItemSlotActive()) { const NormalItemSlot& slot = *itemSlots[column]; if (slot.itemId == 0) { return; } - ITEM_INFO item = LookupClientItem(this->inventory, static_cast(slot.itemId), 1); - if (item.unknown_0000[1] != 0 && this->drag) { - this->drag->BeginItem(this->windows, 7, item, item.quantity, -1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(slot.itemId), 1); + if (item.unknown_0000[1] != 0 && g_modeMgr.GetGameMode()) { + static_cast(g_modeMgr.GetGameMode())->drag.BeginItem(g_windowMgr, 7, item, item.quantity, -1); } } } diff --git a/Source/UI/Shortcuts/ShortcutPress.h b/Source/UI/Shortcuts/ShortcutPress.h deleted file mode 100644 index 1d34daef..00000000 --- a/Source/UI/Shortcuts/ShortcutPress.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTPRESS_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SHORTCUTPRESS_H - -#include "Contents/Skills/ClientSkills.h" -#include "Contents/Items/ItemDescription.h" -#include "Contents/Items/ItemInfo.h" -#include "Contents/UserData/NormalItemSlots.h" -#include "UI/Shortcuts/ShortcutGrid.h" - -class UIFrameWnd; -#include "UI/Window/WindowManagerWindows.h" -class ResourceMgr; -struct ModeDragState; - -struct ShortcutPress { - const std::list& inventory; - ResourceMgr& resources; - WindowManagerWindows& windows; - ModeDragState*& drag; - const bool& restricted; - const bool& itemSlotActive; - unsigned char& currentRow; - - void Press(UIFrameWnd& window, ShortcutGrid& grid, int x, int y, const NormalItemSlot* const* slots, const NormalItemSlot* const* itemSlots); -}; - -#endif diff --git a/Source/UI/Shortcuts/ShortcutTooltip.cpp b/Source/UI/Shortcuts/ShortcutTooltip.cpp index fbe0b389..64391829 100644 --- a/Source/UI/Shortcuts/ShortcutTooltip.cpp +++ b/Source/UI/Shortcuts/ShortcutTooltip.cpp @@ -28,7 +28,7 @@ namespace { void UIShortCutWnd::Slot28(int x, int y) { UIWindow& window = *this; ShortcutGrid& grid = this->m_grid; - const bool itemSlotActive = this->m_shortcuts->itemSlotActive; + const bool itemSlotActive = g_session.ItemSlotActive(); const int column = grid.HitTest(x, y, itemSlotActive, g_session.m_hotkeyPage); if (column != grid.hovered) { grid.hovered = column; diff --git a/Source/UI/Shortcuts/SkillDetailClose.h b/Source/UI/Shortcuts/SkillDetailClose.h deleted file mode 100644 index 3ba32f34..00000000 --- a/Source/UI/Shortcuts/SkillDetailClose.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef RAGNAROK_SOURCE_UI_SHORTCUTS_SKILLDETAILCLOSE_H -#define RAGNAROK_SOURCE_UI_SHORTCUTS_SKILLDETAILCLOSE_H - -#include "UI/Window/UIWindowMgr.h" - -#include -#include - -class UIWindow; - -struct SkillDetailClose { - UIWindow*& window; - int& visible; - std::map& saved; - const std::deque& modalStack; - UIWindow*& reference_4F1D4; - std::map& windowsById; - UIWindowMgr& retirement; - - bool Close(); -}; - -#endif diff --git a/Source/UI/Shortcuts/UIQuickSlotWnd.cpp b/Source/UI/Shortcuts/UIQuickSlotWnd.cpp index ec0a0af1..564cf217 100644 --- a/Source/UI/Shortcuts/UIQuickSlotWnd.cpp +++ b/Source/UI/Shortcuts/UIQuickSlotWnd.cpp @@ -50,7 +50,6 @@ void UIQuickSlotWnd::Slot25(int x, int y) { return; } - QuickSlotPainting& painting = *this->m_painting; const QuickSlotEntry entry = this->m_entries[index]; if (entry.skill) { CSkillInfo skill = g_session.LookupSkill(entry.id); @@ -60,7 +59,7 @@ void UIQuickSlotWnd::Slot25(int x, int y) { } } } else if (entry.id != 0) { - ITEM_INFO item = LookupClientItem(painting.inventory, static_cast(entry.id), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(entry.id), 1); if (item.unknown_0000[1] > 0) { CGameMode* mode = static_cast(g_modeMgr.GetGameMode()); mode->drag.BeginItem(g_windowMgr, 16, item, item.quantity, -1); @@ -94,7 +93,6 @@ void UIQuickSlotWnd::Slot28(int x, int y) { int screenX = (x - 4) / 29 * 29 + 4; this->ToScreen(screenX, screenY); std::string text; - QuickSlotPainting& painting = *this->m_painting; const std::uint32_t id = this->m_entries[this->m_selected].id; if (id == 0) { text.clear(); @@ -110,7 +108,7 @@ void UIQuickSlotWnd::Slot28(int x, int y) { text = SkillUseTextFlat(skill.DisplayName(script), level, sp, ap); } } else { - ITEM_INFO item = LookupClientItem(painting.inventory, static_cast(id), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(id), 1); text = static_cast(FormatOwnedString(LookupMessage(183), item.DisplayName(0).c_str(), item.quantity)); } @@ -167,7 +165,7 @@ void UIQuickSlotWnd::Slot32(int x, int y) { detail->Move(originX - adjustment + x, originY + 33 + rowY); } } else if (entry.id != 0) { - ITEM_INFO item = LookupClientItem(this->m_painting->inventory, static_cast(entry.id), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(entry.id), 1); if (item.unknown_0000[1] > 0) { UIWindow* detail = g_windowMgr.EnsureWindow(12); detail->SendMsg(nullptr, 24, reinterpret_cast(&item), 0, 0, 0); @@ -177,8 +175,8 @@ void UIQuickSlotWnd::Slot32(int x, int y) { // OFFSET: 0x009118C0 // FUNCTION: fn_12520 -UIQuickSlotWnd::UIQuickSlotWnd(QuickSlotPainting& painting) - : UIFrameWnd(0), m_selected(-1), m_painting(&painting) { +UIQuickSlotWnd::UIQuickSlotWnd() + : UIFrameWnd(0), m_selected(-1) { for (int i = 0; i < 2; ++i) { this->m_entries[i].skill = 0; this->m_entries[i].id = 0; @@ -203,7 +201,7 @@ int UIQuickSlotWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argumen } if (source.unknown_0000 == 0) { - ITEM_INFO item = LookupClientItem(this->m_painting->inventory, static_cast(source.itemId), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(source.itemId), 1); if (item.unknown_0000[1] != 0 && item.identified != 0) { entry.id = source.itemId; } @@ -212,7 +210,7 @@ int UIQuickSlotWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argumen CSkillInfo skill = g_session.m_skillBundle.Lookup(source.itemId); if (skill.available == 0) { - std::list& records = this->m_painting->cooldowns.records; + std::list& records = reinterpret_cast(g_session.m_requestTimers).records; const auto record = std::find_if(records.begin(), records.end(), [&](const ShortcutCooldownRecord& value) { return value.id == source.itemId; }); if (record != records.end()) { const auto state = std::find_if(record->alternate.begin(), record->alternate.end(), [&](const CooldownState& value) { return value.slot == index; }); @@ -260,7 +258,7 @@ int UIQuickSlotWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argumen return 0; } - ITEM_INFO item = LookupClientItem(this->m_painting->inventory, static_cast(entry.id), 1); + ITEM_INFO item = LookupClientItem(g_session.m_inventoryItems, static_cast(entry.id), 1); if (item.unknown_0000[1] != 0) { CMode* mode = g_modeMgr.GetGameMode(); switch (item.unknown_0000[0]) { diff --git a/Source/UI/Shortcuts/UIQuickSlotWnd.h b/Source/UI/Shortcuts/UIQuickSlotWnd.h index 92f8232b..65be161a 100644 --- a/Source/UI/Shortcuts/UIQuickSlotWnd.h +++ b/Source/UI/Shortcuts/UIQuickSlotWnd.h @@ -13,16 +13,8 @@ struct ITEM_INFO; class AutomaticSkills; struct QuickSlotPainting { - FontCache& fonts; - const TextLocale& locale; - const std::list& inventory; - std::list& icons; - ShortcutCooldowns& cooldowns; - CooldownDrawing& drawing; - const CooldownClock& clock; RenderCommandPool& commands; CRenderSystemBase& system; - AutomaticSkills& automatic; }; #pragma pack(push, 1) @@ -37,7 +29,7 @@ struct QuickSlotWndInfo; class UIQuickSlotWnd : public UIFrameWnd { public: - UIQuickSlotWnd(QuickSlotPainting& painting); + UIQuickSlotWnd(); void Slot10(int x, int y, std::intptr_t argument) override; void Slot11() override; void Slot15(int width, int height) override; diff --git a/Source/UI/Shortcuts/UIShortCutWnd.cpp b/Source/UI/Shortcuts/UIShortCutWnd.cpp index ca7be1e7..d0725b45 100644 --- a/Source/UI/Shortcuts/UIShortCutWnd.cpp +++ b/Source/UI/Shortcuts/UIShortCutWnd.cpp @@ -1,4 +1,5 @@ #include "Client/Session.h" +#include "Client/Input/Mouse.h" #include "Contents/UserData/CharacterConfigSave.h" #include "Client/Mode/ModeDragState.h" #include "Client/Mode/ModeEvents.h" @@ -6,13 +7,7 @@ #include "Client/Mode/ModeMgr.h" #include "UI/Shortcuts/ShortcutActivation.h" #include "Contents/Skills/ClientSkills.h" -#include "UI/Shortcuts/ShortcutControlEvents.h" #include "UI/Shortcuts/ShortcutCooldowns.h" -#include "UI/Shortcuts/ShortcutDetails.h" -#include "UI/Shortcuts/ShortcutDrop.h" -#include "UI/Shortcuts/ShortcutLayout.h" -#include "UI/Shortcuts/ShortcutPainting.h" -#include "UI/Shortcuts/ShortcutPress.h" #include "UI/Window/UIWindowMgr.inl" #include "UI/Shortcuts/UIShortCutWnd.h" #include "UI/Chat/UINewChatWnd.h" @@ -94,8 +89,8 @@ static bool g_subChatMiniSecondCollapsed; // OFFSET: 0x009122B0 // FUNCTION: fn_12528 -UIShortCutWnd::UIShortCutWnd(ShortcutWindowContext& shortcuts) - : UIFrameWnd(0), m_shortcuts(&shortcuts) { +UIShortCutWnd::UIShortCutWnd() + : UIFrameWnd(0) { this->m_controls.decrease = nullptr; this->m_controls.increase = nullptr; } @@ -123,11 +118,6 @@ void UIShortCutWnd::Move(int x, int y) { g_windowMgr.StoreSnapRectangle(this); } -// OFFSET: 0x00917640 -void UIShortCutWnd::Slot10(int x, int y, std::intptr_t value) { - this->m_shortcuts->drop.Drop(*this, this->m_grid, x, y, *reinterpret_cast(value)); -} - // OFFSET: 0x00940FE0 // FUNCTION: fn_12787 void UIShortCutWnd::Slot11() { @@ -164,26 +154,16 @@ void UIShortCutWnd::Slot15(int, int) { // OFFSET: 0x00932F30 // FUNCTION: fn_12720 void UIShortCutWnd::Slot19() { - const int x = (this->m_shortcuts->cursorX - this->geometry.x); - const int y = (this->m_shortcuts->cursorY - this->geometry.y); - this->m_grid.hovered = this->m_grid.HitTest(x, y, this->m_shortcuts->itemSlotActive, this->m_shortcuts->currentRow); + const int x = (g_mouse.x - this->geometry.x); + const int y = (g_mouse.y - this->geometry.y); + this->m_grid.hovered = this->m_grid.HitTest(x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage); this->Invalidate(); } -// OFFSET: 0x0092F8E0 -void UIShortCutWnd::Paint() { - this->m_shortcuts->painting.Paint(*this, this->m_grid, this->m_slots, this->m_itemSlots); -} - -// OFFSET: 0x009310E0 -void UIShortCutWnd::Slot25(int x, int y) { - this->m_shortcuts->press.Press(*this, this->m_grid, x, y, this->m_slots, this->m_itemSlots); -} - // OFFSET: 0x00930900 void UIShortCutWnd::Slot26(int x, int y) { ActivateShortcut( - *this, this->m_grid, x, y, this->m_shortcuts->itemSlotActive, this->m_shortcuts->currentRow, this->m_slots, this->m_shortcuts->automatic + *this, this->m_grid, x, y, g_session.ItemSlotActive(), g_session.m_hotkeyPage, this->m_slots, *reinterpret_cast(g_session.unknown_7FB4) ); } @@ -194,70 +174,65 @@ void UIShortCutWnd::Slot31(int x, int y) { this->Slot11(); } -// OFFSET: 0x009332D0 -void UIShortCutWnd::Slot32(int x, int y) { - this->m_shortcuts->details.Open(*this, this->m_grid, x, y, this->m_slots, this->m_itemSlots); -} - // INLINED -inline void ShortcutControlEvents::Click(int id) { +inline void UIShortCutWnd::ClickControl(int id) { switch (id) { case 201: g_windowMgr.ShowShortcutWindow(0); return; case 216: - if (this->window.geometry.visible == 0) { + if (this->geometry.visible == 0) { g_windowMgr.ShowShortcutWindow(1); return; } - this->grid.rows = this->grid.rows + 1; + this->m_grid.rows = this->m_grid.rows + 1; - if (this->grid.rows > 4) { - this->grid.rows = 1; + if (this->m_grid.rows > 4) { + this->m_grid.rows = 1; g_windowMgr.ShowShortcutWindow(0); } - this->window.SendMsg(nullptr, 14, 0, 0, 0, 0); + this->SendMsg(nullptr, 14, 0, 0, 0, 0); return; case 217: - if (this->grid.rows > 1) { - --this->grid.rows; + if (this->m_grid.rows > 1) { + --this->m_grid.rows; } - this->window.SendMsg(nullptr, 14, 0, 0, 0, 0); + this->SendMsg(nullptr, 14, 0, 0, 0, 0); return; case 549: { const bool checked = g_session.GetOption(10) == 0; g_session.SetOption(10, checked ? 1 : 0, 0); - this->controls.bank->geometry.unknown_0030 = checked ? 1 : 0; - this->controls.bank->Invalidate(); + this->m_controls.bank->geometry.unknown_0030 = checked ? 1 : 0; + this->m_controls.bank->Invalidate(); - for (ShortcutCooldownRecord& record : this->cooldowns.records) { + for (ShortcutCooldownRecord& record : reinterpret_cast(g_session.m_requestTimers).records) { record.main.clear(); } - this->window.SendMsg(nullptr, 23, 0, 0, 0, 0); + this->SendMsg(nullptr, 23, 0, 0, 0, 0); return; } case 588: case 589: { - this->itemSlotActive = id == 588; - const bool active = this->itemSlotActive; + g_session.ItemSlotActive() = id == 588; + const bool active = g_session.ItemSlotActive(); - this->controls.showItems->Enable(active ? 0 : 1); - this->controls.showItems->SetDisabled(active ? 1 : 0); - this->controls.showItems->Invalidate(); + this->m_controls.showItems->Enable(active ? 0 : 1); + this->m_controls.showItems->SetDisabled(active ? 1 : 0); + this->m_controls.showItems->Invalidate(); - this->controls.hideItems->Enable(active ? 1 : 0); - this->controls.hideItems->SetDisabled(active ? 0 : 1); - this->controls.hideItems->Invalidate(); + this->m_controls.hideItems->Enable(active ? 1 : 0); + this->m_controls.hideItems->SetDisabled(active ? 0 : 1); + this->m_controls.hideItems->Invalidate(); - this->window.SendMsg(nullptr, 14, 0, 0, 0, 0); + this->SendMsg(nullptr, 14, 0, 0, 0, 0); return; } @@ -267,69 +242,57 @@ inline void ShortcutControlEvents::Click(int id) { } // INLINED -inline void ShortcutLayout::PlaceRowButtons() { - this->decrease.Move(this->window.geometry.width - this->decrease.geometry.width - 2, this->grid.rows * 33 - 28); - this->increase.Move(this->window.geometry.width - this->increase.geometry.width - 2, this->grid.rows * 33 - 13); - this->decrease.Enable(this->grid.rows == 1 ? 0 : 1); - this->increase.Enable(1); - this->increase.SetDisabled(this->grid.rows == 4 ? 1 : 0); - this->increase.Invalidate(); +inline void UIShortCutWnd::PlaceRowButtons() { + this->m_controls.decrease->Move(this->geometry.width - this->m_controls.decrease->geometry.width - 2, this->m_grid.rows * 33 - 28); + this->m_controls.increase->Move(this->geometry.width - this->m_controls.increase->geometry.width - 2, this->m_grid.rows * 33 - 13); + this->m_controls.decrease->Enable(this->m_grid.rows == 1 ? 0 : 1); + this->m_controls.increase->Enable(1); + this->m_controls.increase->SetDisabled(this->m_grid.rows == 4 ? 1 : 0); + this->m_controls.increase->Invalidate(); } // INLINED -inline void ShortcutLayout::ResizeRows() { - const int height = (this->itemSlotActive ? 43 : 10) + this->grid.rows * 33; - if (height == this->window.geometry.height) { +inline void UIShortCutWnd::ResizeRows() { + const int height = (g_session.ItemSlotActive() ? 43 : 10) + this->m_grid.rows * 33; + if (height == this->geometry.height) { return; } - this->window.Resize(this->window.geometry.width, height); + this->Resize(this->geometry.width, height); - this->decrease.Move(this->window.geometry.width - this->decrease.geometry.width - 2, this->grid.rows * 33 - 28); - this->increase.Move(this->window.geometry.width - this->increase.geometry.width - 2, this->grid.rows * 33 - 13); - this->showItems.Move(247, height - 10); - this->hideItems.Move(247, height - 10); - this->decrease.Enable(this->grid.rows == 1 ? 0 : 1); - this->increase.Enable(1); - this->increase.SetDisabled(this->grid.rows == 4 ? 1 : 0); - this->increase.Invalidate(); - this->window.Slot11(); + this->m_controls.decrease->Move(this->geometry.width - this->m_controls.decrease->geometry.width - 2, this->m_grid.rows * 33 - 28); + this->m_controls.increase->Move(this->geometry.width - this->m_controls.increase->geometry.width - 2, this->m_grid.rows * 33 - 13); + this->m_controls.showItems->Move(247, height - 10); + this->m_controls.hideItems->Move(247, height - 10); + this->m_controls.decrease->Enable(this->m_grid.rows == 1 ? 0 : 1); + this->m_controls.increase->Enable(1); + this->m_controls.increase->SetDisabled(this->m_grid.rows == 4 ? 1 : 0); + this->m_controls.increase->Invalidate(); + this->Slot11(); } // INLINED -inline void ShortcutLayout::Restore(NormalItemSlotWindow* value) { - this->saved = value; - if (!value->IsValid(this->screenWidth, this->screenHeight, this->itemSlotActive)) { +inline void UIShortCutWnd::RestoreLayout(NormalItemSlotWindow* value) { + this->m_saved = value; + if (!value->IsValid(g_windowMgr.unknown_047C, g_windowMgr.unknown_0480, g_session.ItemSlotActive())) { value->Reset(); } const int height = value->height; - this->window.Resize(this->window.geometry.width, height); - const int extent = this->itemSlotActive ? height - 43 : height; - this->showItems.Move(247, height - 10); - this->hideItems.Move(247, height - 10); - this->showItems.Enable(this->itemSlotActive ? 0 : 1); - this->showItems.SetDisabled(this->itemSlotActive ? 1 : 0); - this->showItems.Invalidate(); - this->hideItems.Enable(this->itemSlotActive ? 1 : 0); - this->hideItems.SetDisabled(this->itemSlotActive ? 0 : 1); - this->hideItems.Invalidate(); - this->grid.rows = extent / 33; + this->Resize(this->geometry.width, height); + const int extent = g_session.ItemSlotActive() ? height - 43 : height; + this->m_controls.showItems->Move(247, height - 10); + this->m_controls.hideItems->Move(247, height - 10); + this->m_controls.showItems->Enable(g_session.ItemSlotActive() ? 0 : 1); + this->m_controls.showItems->SetDisabled(g_session.ItemSlotActive() ? 1 : 0); + this->m_controls.showItems->Invalidate(); + this->m_controls.hideItems->Enable(g_session.ItemSlotActive() ? 1 : 0); + this->m_controls.hideItems->SetDisabled(g_session.ItemSlotActive() ? 0 : 1); + this->m_controls.hideItems->Invalidate(); + this->m_grid.rows = extent / 33; this->PlaceRowButtons(); - this->window.SendMsg(nullptr, 23, 0, 0, 0, 0); - this->window.Move(value->x, value->y); -} - -// OFFSET: 0x00940FE0 -inline void ShortcutLayout::Persist() { - if (!this->saved) { - return; - } - - this->saved->x = this->window.geometry.x; - this->saved->y = this->window.geometry.y; - this->saved->width = this->window.geometry.width; - this->saved->height = this->window.geometry.height; + this->SendMsg(nullptr, 23, 0, 0, 0, 0); + this->Move(value->x, value->y); } // INLINED @@ -407,31 +370,14 @@ inline void UseShortcutSlot(const NormalItemSlot& slot) { // OFFSET: 0x0093B450 // FUNCTION: fn_12760 int UIShortCutWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) { - ShortcutWindowContext& owner = *this->m_shortcuts; - switch (message) { - case 6: { - ShortcutControlEvents events{*this, this->m_grid, this->m_controls, reinterpret_cast(g_session.m_requestTimers), owner.itemSlotActive}; - events.Click(static_cast(a)); + case 6: + this->ClickControl(static_cast(a)); return 0; - } - case 14: { - ShortcutLayout layout{ - *this, - this->m_grid, - this->m_saved, - *this->m_controls.decrease, - *this->m_controls.increase, - *this->m_controls.showItems, - *this->m_controls.hideItems, - owner.itemSlotActive, - g_windowMgr.unknown_047C, - g_windowMgr.unknown_0480 - }; - layout.ResizeRows(); + case 14: + this->ResizeRows(); return 0; - } case 23: { ShortcutCooldowns& cooldowns = reinterpret_cast(g_session.m_requestTimers); @@ -480,22 +426,9 @@ int UIShortCutWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std:: return 0; } - case 34: { - ShortcutLayout layout{ - *this, - this->m_grid, - this->m_saved, - *this->m_controls.decrease, - *this->m_controls.increase, - *this->m_controls.showItems, - *this->m_controls.hideItems, - owner.itemSlotActive, - g_windowMgr.unknown_047C, - g_windowMgr.unknown_0480 - }; - layout.Restore(reinterpret_cast(a)); + case 34: + this->RestoreLayout(reinterpret_cast(a)); return 0; - } case 41: { const int index = 9 * static_cast(b) + static_cast(a); @@ -504,7 +437,7 @@ int UIShortCutWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std:: } case 143: - if (reinterpret_cast(g_session.m_requestTimers).RotateRows(static_cast(a), static_cast(b), g_session.unknown_06FC, g_session.unknown_06A8, owner.clock)) { + if (reinterpret_cast(g_session.m_requestTimers).RotateRows(static_cast(a), static_cast(b), g_session.unknown_06FC, g_session.unknown_06A8)) { this->SendMsg(nullptr, 23, 0, 0, 0, 0); } diff --git a/Source/UI/Shortcuts/UIShortCutWnd.h b/Source/UI/Shortcuts/UIShortCutWnd.h index be0ad5c4..ebd7cff3 100644 --- a/Source/UI/Shortcuts/UIShortCutWnd.h +++ b/Source/UI/Shortcuts/UIShortCutWnd.h @@ -5,34 +5,14 @@ #include "UI/Shortcuts/ShortcutGrid.h" #include "UI/Window/UIFrameWnd.h" -struct ShortcutPainting; -struct ShortcutPress; -struct ShortcutDrop; -struct ShortcutDetails; -struct CooldownClock; struct ModeDragState; +struct ShortcutPainting; struct NormalItemSlot; struct NormalItemSlotWindow; -class AutomaticSkills; - -struct ShortcutWindowContext { - ShortcutPainting& painting; - ShortcutPress& press; - ShortcutDrop& drop; - ShortcutDetails& details; - AutomaticSkills& automatic; - const CooldownClock& clock; - bool& itemSlotActive; - unsigned char& currentRow; - int& rotation0; - int& rotation1; - const int& cursorX; - const int& cursorY; -}; class UIShortCutWnd : public UIFrameWnd { public: - UIShortCutWnd(ShortcutWindowContext& shortcuts); + UIShortCutWnd(); ~UIShortCutWnd() override; bool Slot03() override; @@ -52,13 +32,19 @@ public: friend class CGameMode; +private: + void ClickControl(int id); + void PlaceRowButtons(); + void ResizeRows(); + void RestoreLayout(NormalItemSlotWindow* value); + private: ShortcutControls m_controls; NormalItemSlotWindow* m_saved; NormalItemSlot* m_slots[36]; ShortcutGrid m_grid; NormalItemSlot* m_itemSlots[9]; - ShortcutWindowContext* m_shortcuts; + ShortcutPainting* m_painting; }; #if defined(_WIN32) && !defined(_WIN64) diff --git a/Source/UI/Window/UIWindowFactory.cpp b/Source/UI/Window/UIWindowFactory.cpp index 8f86c118..89e36835 100644 --- a/Source/UI/Window/UIWindowFactory.cpp +++ b/Source/UI/Window/UIWindowFactory.cpp @@ -12,10 +12,6 @@ #include -struct LayoutWindowContexts { - QuickSlotPainting& quickSlots; -}; - // GLOBAL: gl_25184 bool g_searchStoreInfoCreated; @@ -37,7 +33,6 @@ UIWindow* UIWindowMgr::CreateLayoutWindow(int id) { std::string yKey; std::string xKey; if (window == nullptr) { - LayoutWindowContexts& contexts = *reinterpret_cast(this); switch (id) { case 0x9C: window = new UIHotKeyWnd(); @@ -47,7 +42,7 @@ UIWindow* UIWindowMgr::CreateLayoutWindow(int id) { window = new UIEntryQueueWnd(); break; case 0x9F: - window = new UIQuickSlotWnd(contexts.quickSlots); + window = new UIQuickSlotWnd(); break; case 0xB5: window = new UISerachStoreInfoWnd();