When holding air, inventory should open at middle instead of very bottom

This commit is contained in:
UnknownShadow200 2018-05-07 08:57:29 +10:00
parent c55400849c
commit 13ef73f9b7
3 changed files with 6 additions and 1 deletions

View File

@ -155,6 +155,8 @@ namespace ClassicalSharp.Gui.Widgets {
for (int i = 0; i < Elements.Length; i++) { for (int i = 0; i < Elements.Length; i++) {
if (Elements[i] == block) SelectedIndex = i; if (Elements[i] == block) SelectedIndex = i;
} }
// When holding air, inventory should open at middle
if (block == Block.Air) SelectedIndex = -1;
scroll.ScrollY = (SelectedIndex / ElementsPerRow) - (MaxRowsDisplayed - 1); scroll.ScrollY = (SelectedIndex / ElementsPerRow) - (MaxRowsDisplayed - 1);
scroll.ClampScrollY(); scroll.ClampScrollY();

View File

@ -18,7 +18,7 @@ typedef struct AsyncRequest_ {
DateTime TimeAdded; DateTime TimeAdded;
DateTime TimeDownloaded; DateTime TimeDownloaded;
UInt8 RequestType; UInt16 ResponseCode;
union { union {
struct { void* Ptr; UInt32 Size; } ResultData; struct { void* Ptr; UInt32 Size; } ResultData;
@ -29,6 +29,7 @@ typedef struct AsyncRequest_ {
DateTime LastModified; /* Time item cached at (if at all) */ DateTime LastModified; /* Time item cached at (if at all) */
UInt8 Etag[String_BufferSize(STRING_SIZE)]; /* ETag of cached item (if any) */ UInt8 Etag[String_BufferSize(STRING_SIZE)]; /* ETag of cached item (if any) */
UInt8 RequestType;
} AsyncRequest; } AsyncRequest;
void ASyncRequest_Free(AsyncRequest* request); void ASyncRequest_Free(AsyncRequest* request);

View File

@ -867,6 +867,8 @@ void TableWidget_SetBlockTo(TableWidget* widget, BlockID block) {
for (i = 0; i < widget->ElementsCount; i++) { for (i = 0; i < widget->ElementsCount; i++) {
if (widget->Elements[i] == block) widget->SelectedIndex = i; if (widget->Elements[i] == block) widget->SelectedIndex = i;
} }
/* When holding air, inventory should open at middle */
if (block == BLOCK_AIR) widget->SelectedIndex = -1;
widget->Scroll.ScrollY = widget->SelectedIndex / widget->ElementsPerRow; widget->Scroll.ScrollY = widget->SelectedIndex / widget->ElementsPerRow;
widget->Scroll.ScrollY -= (TABLE_MAX_ROWS_DISPLAYED - 1); widget->Scroll.ScrollY -= (TABLE_MAX_ROWS_DISPLAYED - 1);