Make inventory menu in classic mode closer to original classic

This commit is contained in:
UnknownShadow200 2022-12-01 19:10:20 +11:00
parent 651812639f
commit 6761389db3
3 changed files with 24 additions and 25 deletions

View File

@ -632,14 +632,10 @@ void HotbarWidget_SetFont(struct HotbarWidget* w, struct FontDesc* font) {
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------TableWidget-------------------------------------------------------* *-------------------------------------------------------TableWidget-------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
static int Table_X(struct TableWidget* w) { return w->x - w->paddingX; } static int Table_X(struct TableWidget* w) { return w->x - w->paddingL; }
static int Table_Y(struct TableWidget* w) { return w->y - w->paddingTopY; } static int Table_Y(struct TableWidget* w) { return w->y - w->paddingT; }
static int Table_Width(struct TableWidget* w) { static int Table_Width(struct TableWidget* w) { return w->width + w->paddingL + w->paddingR; }
return w->blocksPerRow * w->cellSizeX + w->paddingX * 2; static int Table_Height(struct TableWidget* w) { return w->height + w->paddingT + w->paddingB; }
}
static int Table_Height(struct TableWidget* w) {
return w->rowsVisible * w->cellSizeY + w->paddingTopY + w->paddingMaxY;
}
#define TABLE_MAX_VERTICES (8 * 10 * ISOMETRICDRAWER_MAXVERTICES) #define TABLE_MAX_VERTICES (8 * 10 * ISOMETRICDRAWER_MAXVERTICES)
@ -743,8 +739,8 @@ static void TableWidget_Render(void* widget, double delta) {
/* We want to always draw the selected block on top of others */ /* We want to always draw the selected block on top of others */
/* TODO: Need two size arguments, in case X/Y dpi differs */ /* TODO: Need two size arguments, in case X/Y dpi differs */
if (i == w->selectedIndex) continue; if (i == w->selectedIndex) continue;
IsometricDrawer_DrawBatch(w->blocks[i], cellSizeX * 0.7f / 2.0f, IsometricDrawer_DrawBatch(w->blocks[i],
x + cellSizeX / 2, y + cellSizeY / 2); w->normBlockSize, x + cellSizeX / 2, y + cellSizeY / 2);
} }
i = w->selectedIndex; i = w->selectedIndex;
@ -752,8 +748,7 @@ static void TableWidget_Render(void* widget, double delta) {
TableWidget_GetCoords(w, i, &x, &y); TableWidget_GetCoords(w, i, &x, &y);
IsometricDrawer_DrawBatch(w->blocks[i], IsometricDrawer_DrawBatch(w->blocks[i],
(cellSizeX + w->selBlockExpand) * 0.7f / 2.0f, w->selBlockSize, x + cellSizeX / 2, y + cellSizeY / 2);
x + cellSizeX / 2, y + cellSizeY / 2);
} }
IsometricDrawer_EndBatch(); IsometricDrawer_EndBatch();
} }
@ -772,14 +767,17 @@ void TableWidget_Recreate(struct TableWidget* w) {
static void TableWidget_Reposition(void* widget) { static void TableWidget_Reposition(void* widget) {
struct TableWidget* w = (struct TableWidget*)widget; struct TableWidget* w = (struct TableWidget*)widget;
float scale = w->scale; float scale = Math_SqrtF(w->scale);
int cellSize; int cellSize, blockSize;
cellSize = (int)(50 * Math_SqrtF(scale)); cellSize = Game_ClassicMode ? 48 : 50;
w->cellSizeX = Display_ScaleX(cellSize); w->cellSizeX = Display_ScaleX(cellSize * scale);
w->cellSizeY = Display_ScaleY(cellSize); w->cellSizeY = Display_ScaleY(cellSize * scale);
w->selBlockExpand = 25.0f * Math_SqrtF(scale); blockSize = Game_ClassicMode ? 40 : 50;
blockSize = Display_ScaleX(blockSize * scale);
w->normBlockSize = (blockSize ) * 0.7f / 2.0f;
w->selBlockSize = (blockSize + 25 * scale) * 0.7f / 2.0f;
w->rowsVisible = min(8, w->rowsTotal); /* 8 rows max */ w->rowsVisible = min(8, w->rowsTotal); /* 8 rows max */
do { do {
@ -918,9 +916,10 @@ void TableWidget_Create(struct TableWidget* w) {
w->lastX = -20; w->lastY = -20; w->lastX = -20; w->lastY = -20;
w->scale = 1; w->scale = 1;
w->paddingX = Display_ScaleX(15); w->paddingL = Display_ScaleX(Game_ClassicMode ? 20 : 15);
w->paddingTopY = Display_ScaleY(15 + 20); w->paddingR = Display_ScaleX(Game_ClassicMode ? 28 : 15);
w->paddingMaxY = Display_ScaleX(15); w->paddingT = Display_ScaleY(Game_ClassicMode ? 46 : 35);
w->paddingB = Display_ScaleY(Game_ClassicMode ? 14 : 15);
} }
void TableWidget_SetBlockTo(struct TableWidget* w, BlockID block) { void TableWidget_SetBlockTo(struct TableWidget* w, BlockID block) {

View File

@ -88,7 +88,7 @@ struct TableWidget {
int rowsTotal, rowsVisible; int rowsTotal, rowsVisible;
int lastCreatedIndex; int lastCreatedIndex;
int selectedIndex, cellSizeX, cellSizeY; int selectedIndex, cellSizeX, cellSizeY;
float selBlockExpand; float normBlockSize, selBlockSize;
GfxResourceID vb; GfxResourceID vb;
cc_bool pendingClose; cc_bool pendingClose;
float scale; float scale;
@ -96,7 +96,7 @@ struct TableWidget {
BlockID blocks[BLOCK_COUNT]; BlockID blocks[BLOCK_COUNT];
struct ScrollbarWidget scroll; struct ScrollbarWidget scroll;
int lastX, lastY, paddingX; int lastX, lastY, paddingX;
int paddingTopY, paddingMaxY; int paddingL, paddingR, paddingT, paddingB;
void (*UpdateTitle)(BlockID block); void (*UpdateTitle)(BlockID block);
}; };

View File

@ -150,7 +150,7 @@ mergeInto(LibraryManager.library, {
}) })
.catch(function(error) { .catch(function(error) {
ccall('Platform_LogError', 'void', ['string'], ['&cError downloading file']); ccall('Platform_LogError', 'void', ['string'], ['&cError downloading file']);
ccall('Platform_LogError', 'void', ['string'], [' &c' + err]); ccall('Platform_LogError', 'void', ['string'], [' &c' + error]);
}) })
.finally(function(result) { .finally(function(result) {
if (path) CCFS.unlink(path); if (path) CCFS.unlink(path);