public static void DrawInventory() { int i, j; int num, selected_num, item; var index = new int[Defines.MAX_ITEMS]; string @string; int x, y; string binding; string bind; int selected; int top; selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; num = 0; selected_num = 0; for (i = 0; i < Defines.MAX_ITEMS; i++) { if (i == selected) { selected_num = num; } if (Globals.cl.inventory[i] != 0) { index[num] = i; num++; } } // determine scroll point top = selected_num - CL_inv.DISPLAY_ITEMS / 2; if (num - top < CL_inv.DISPLAY_ITEMS) { top = num - CL_inv.DISPLAY_ITEMS; } if (top < 0) { top = 0; } x = (Globals.viddef.getWidth() - 256) / 2; y = (Globals.viddef.getHeight() - 240) / 2; // repaint everything next frame SCR.DirtyScreen(); Globals.re.DrawPic(x, y + 8, "inventory"); y += 24; x += 24; CL_inv.Inv_DrawString(x, y, "hotkey ### item"); CL_inv.Inv_DrawString(x, y + 8, "------ --- ----"); y += 16; for (i = top; i < num && i < top + CL_inv.DISPLAY_ITEMS; i++) { item = index[i]; // search for a binding //Com_sprintf (binding, sizeof(binding), "use %s", // cl.configstrings[CS_ITEMS+item]); binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; bind = ""; for (j = 0; j < 256; j++) { if (Globals.keybindings[j] != null && Globals.keybindings[j].Equals(binding)) { bind = Key.KeynumToString(j); break; } } @string = Com.sprintf( "%6s %3i %s", bind, Globals.cl.inventory[item], Globals.cl.configstrings[Defines.CS_ITEMS + item] ); if (item != selected) { @string = CL_inv.getHighBitString(@string); } else // draw a blinky cursor by the selected item { if (((int)(Globals.cls.realtime * 10) & 1) != 0) { Globals.re.DrawChar(x - 8, y, 15); } } CL_inv.Inv_DrawString(x, y, @string); y += 8; } }
public static void DrawInventory() { int i, j; int num, selected_num, item; int[] index = new int[Defines.MAX_ITEMS]; string string_renamed; int x, y; string binding; string bind; int selected; int top; selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; num = 0; selected_num = 0; for (i = 0; i < Defines.MAX_ITEMS; i++) { if (i == selected) { selected_num = num; } if (Globals.cl.inventory[i] != 0) { index[num] = i; num++; } } top = selected_num - DISPLAY_ITEMS / 2; if (num - top < DISPLAY_ITEMS) { top = num - DISPLAY_ITEMS; } if (top < 0) { top = 0; } x = (Globals.viddef.GetWidth() - 256) / 2; y = (Globals.viddef.GetHeight() - 240) / 2; SCR.DirtyScreen(); Globals.re.DrawPic(x, y + 8, "inventory"); y += 24; x += 24; Inv_DrawString(x, y, "hotkey ### item"); Inv_DrawString(x, y + 8, "------ --- ----"); y += 16; for (i = top; i < num && i < top + DISPLAY_ITEMS; i++) { item = index[i]; binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; bind = ""; for (j = 0; j < 256; j++) { if (Globals.keybindings[j] != null && Globals.keybindings[j].Equals(binding)) { bind = Key.KeynumToString(j); break; } } string_renamed = Com.Sprintf("%6s %3i %s", bind, Globals.cl.inventory[item], Globals.cl.configstrings[Defines.CS_ITEMS + item]); if (item != selected) { string_renamed = GetHighBitString(string_renamed); } else { if (((int)(Globals.cls.realtime * 10) & 1) != 0) { Globals.re.DrawChar(x - 8, y, 15); } } Inv_DrawString(x, y, string_renamed); y += 8; } }