From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/ScrolledSelectionList.cpp | 358 +++++++++++++++++++++++++++++ 1 file changed, 358 insertions(+) create mode 100644 Minecraft.Client/ScrolledSelectionList.cpp (limited to 'Minecraft.Client/ScrolledSelectionList.cpp') diff --git a/Minecraft.Client/ScrolledSelectionList.cpp b/Minecraft.Client/ScrolledSelectionList.cpp new file mode 100644 index 00000000..9b7367ce --- /dev/null +++ b/Minecraft.Client/ScrolledSelectionList.cpp @@ -0,0 +1,358 @@ +#include "stdafx.h" +#include "ScrolledSelectionList.h" +#include "Button.h" +#include "Tesselator.h" +#include "Textures.h" +#include "..\Minecraft.World\System.h" + +ScrolledSelectionList::ScrolledSelectionList(Minecraft *minecraft, int width, int height, int y0, int y1, int itemHeight) +{ + this->minecraft = minecraft; + this->width = width; + this->height = height; + this->y0 = y0; + this->y1 = y1; + this->itemHeight = itemHeight; + this->x0 = 0; + this->x1 = width; + + + // 4J Stu - Smoe default initialisers + upId = 0; + downId = 0; + + yDrag = 0.0f; + yDragScale = 0.0f; + yo = 0.0f; + + lastSelection = 0; + lastSelectionTime = 0; + + renderSelection = false; + _renderHeader = false; + headerHeight = 0; + //End +} + +void ScrolledSelectionList::setRenderSelection(bool renderSelection) +{ + this->renderSelection = renderSelection; +} + +void ScrolledSelectionList::setRenderHeader(bool renderHeader, int headerHeight) +{ + this->_renderHeader = renderHeader; + this->headerHeight = headerHeight; + + if (!_renderHeader) + { + this->headerHeight = 0; + } +} + +int ScrolledSelectionList::getMaxPosition() +{ + return getNumberOfItems() * itemHeight + headerHeight; +} + +void ScrolledSelectionList::renderHeader(int x, int y, Tesselator *t) +{ +} + +void ScrolledSelectionList::clickedHeader(int headerMouseX, int headerMouseY) +{ +} + +void ScrolledSelectionList::renderDecorations(int mouseX, int mouseY) +{ +} + + int ScrolledSelectionList::getItemAtPosition(int x, int y) +{ + int x0 = width / 2 - (92 + 16 + 2); + int x1 = width / 2 + (92 + 16 + 2); + + int clickSlotPos = (y - y0 - headerHeight + (int) yo - 4); + int slot = clickSlotPos / itemHeight; + if (x >= x0 && x <= x1 && slot >= 0 && clickSlotPos >= 0 && slot < getNumberOfItems()) + { + return slot; + } + return -1; +} + +void ScrolledSelectionList::init(vector