Guest User

Necro Inventory Thingy

a guest
Oct 12th, 2013
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.63 KB | None | 0 0
  1. public function showInventory(temp.bag) {
  2.   this.bagOpen = true;
  3.   if ( isObject("Inventory_Window") ) {
  4.     Inventory_Window.destroy();
  5.   }
  6.   play("necro_scroll-1_1.wav");
  7.  
  8.   new GuiWindowCtrl("Inventory_Window") {
  9.     profile = Necro_Window;
  10.     profile.modal = false;
  11.     profile.cankeyfocus = false;
  12.     profile.makefirstresponder = false;
  13.     width = 360;
  14.     x = screenwidth - 362;
  15.     text = "Inventory - Bag " @ temp.bag;
  16.    
  17.     canclose = canminimize = canmaximize = canmove = canresize = false;
  18.  
  19.     new GuiScrollCtrl("Inventory_Scroll") {
  20.       profile = Necro_Scroll;
  21.       useownprofile = true;
  22.       profile.modal = true;
  23.       profile.cankeyfocus = false;
  24.       profile.makefirstresponder = false;
  25.       x = 11;
  26.       y = 29;
  27.       width = 340;
  28.       hScrollBar = "alwaysOff";
  29.       vScrollBar = "alwaysOff";
  30.       this.clearControls();
  31.       thiso.catchEvent(this, "onMouseDown", "onSelectItem");
  32.       thiso.catchEvent(this, "onRightMouseDown", "onDisplayOptions");
  33.       //Item Box Display
  34.       for (temp.i = 0; temp.i <= thiso.items.size(); temp.i ++) {
  35.         new GuiControl("Inventory_Item_" @ temp.i) {
  36.           width = height = 32;
  37.           x = 12 + (40 * (temp.i % 8));
  38.           y = 8 + (40 * int(temp.i / 8));
  39.           useownprofile = true;
  40.           profile.modal = false;
  41.           profile.cankeyfocus = false;
  42.           profile.makefirstresponder = false;
  43.          
  44.           new GuiBitmapCtrl("Inventory_Item_" @ temp.i @ "_box") {
  45.             bitmap = "necro_gui_iconbox.gif";
  46.             x = y = 0;
  47.             width = height = 32;
  48.             useownprofile = true;
  49.             profile.modal = false;
  50.             profile.cankeyfocus = false;
  51.             profile.makefirstresponder = false;
  52.           }
  53.           Inventory_Window.height = ((round(temp.i / 8)) * 40) + 53;
  54.           Inventory_Scroll.height = Inventory_Window.height - 40;
  55.           Inventory_Window.y = screenheight - 70 - Inventory_Window.height;
  56.         }
  57.       }  
  58.       //Item Display
  59.       temp.getItems = makevar("clientr.items"@ thiso.backpack).size();
  60.       for (temp.v = 0; temp.v <= temp.getItems; temp.v ++ ) {
  61.         temp.itemName = makevar("clientr.items"@ thiso.backpack)[v];
  62.         temp.itemIcon = makevar("clientr.item_"@ temp.itemName)[3];
  63.         temp.itemAmount = makevar("clientr.item_amount_"@ temp.itemName);
  64.         new GuiBitmapCtrl("Inventory_Item_" @ temp.v @ "_Icon") {
  65.           bitmap = temp.itemIcon;
  66.           x = 12 + (40 * (temp.v % 8));
  67.           y = 8 + (40 * int(temp.v / 8));
  68.           width = height = 32;
  69.           useownprofile = true;
  70.           profile.modal = false;
  71.           profile.cankeyfocus = false;
  72.           profile.makefirstresponder = false;
  73.         }
  74.         new GuiTextCtrl("Inventory_Item_" @ temp.v @ "_Amount") {
  75.           profile = Necro_Text;
  76.           profile.modal = false;
  77.           profile.active = false;
  78.           profile.cankeyfocus = false;
  79.           profile.makefirstresponder = false;
  80.           useownprofile = true;
  81.           profile.fontSize = 10;
  82.           width = 80;
  83.           height = 16;
  84.           x = 13 + (40 * (temp.v % 8));
  85.           y = 26 + (40 * int(temp.v / 8));
  86.           alpha = 0.8;
  87.           text = (temp.itemAmount == 0 ? "" : temp.itemAmount);
  88.           style = "bc";
  89.         }
  90.       }  
  91.     }
  92.   }
  93.   with (Inventory_Window.createAnimation()) {
  94.     transition = "fadein";
  95.     duration = 0.2;
  96.   }
  97.   with (Inventory_Window.createAnimation()) {
  98.     transition = "moveinbottom";
  99.     duration = 0.2;
  100.     timing = "sinus";
  101.   }
  102.   onTimeOut();
  103. }
  104.  
  105. function onTimeOut() {
  106.   temp.local = Inventory_Scroll.globaltolocalcoord({mousescreenx, mousescreeny});
  107.  
  108.   temp.index_row = int(temp.local[1] / 40) + 1;
  109.   temp.index_col = int(temp.local[0] / 40);
  110.  
  111.   temp.cell = 8 * temp.index_row - 8 + temp.index_col;
  112.   temp.cell_up = 8 * (temp.index_row - 1) - 8 + temp.index_col;
  113.   temp.cell_left = 8 * temp.index_row - 8 + (temp.index_col - 1);
  114.   temp.cell_down = 8 * (temp.index_row + 1) - 8 + temp.index_col;
  115.   temp.cell_right = 8 * temp.index_row - 8 + (temp.index_col + 1);
  116.  
  117.   for (temp.i = 0; temp.i <= thiso.items.size(); temp.i ++) {
  118.     ("Inventory_Item_" @ temp.i @ "_box").alpha = 0.8;
  119.     ("Inventory_Item_" @ temp.i @ "_Icon").alpha = 0.6;
  120.     ("Inventory_Item_" @ temp.i @ "_Amount").alpha = 0.6;
  121.     ("Inventory_Item_" @ temp.i @ "_box").bitmap = "necro_gui_iconbox.gif";
  122.     switch (temp.i) {
  123.       case temp.cell:
  124.         ("Inventory_Item_" @ temp.i @ "_box").alpha = 1;
  125.         ("Inventory_Item_" @ temp.i @ "_Icon").alpha = 1;
  126.         ("Inventory_Item_" @ temp.i @ "_Amount").alpha = 1;
  127.         ("Inventory_Item_" @ temp.i @ "_box").bitmap = "necro_gui_iconbox2.gif";
  128.       break;
  129.       case temp.cell_up:
  130.       case temp.cell_left:
  131.       case temp.cell_down:
  132.       case temp.cell_right:
  133.         ("Inventory_Item_" @ temp.i @ "_box").alpha = 0.4;
  134.         ("Inventory_Item_" @ temp.i @ "_Icon").alpha = 0.4;
  135.         ("Inventory_Item_" @ temp.i @ "_Amount").alpha = 0.4;
  136.       break;
  137.     }
  138.   }
  139.  
  140.   this.cell_selected = temp.cell;
  141.   setTimer(0.05);
  142. }
  143.  
  144. function onSelectItem() {
  145.   temp.slot = this.cell_selected;
  146.  
  147.   if (temp.slot <= this.items.size()) {
  148.     play("necro_click2.wav");
  149.     temp.itemName = makevar("clientr.items"@ thiso.backpack)[slot];
  150.     temp.itemRealName = makevar("clientr.item_"@ temp.itemName)[1];
  151.     if ( temp.itemRealName != NULL ) player.chat = "Debug:"SPC (temp.slot+1) SPC temp.itemRealName;
  152.   }
  153. }
  154.  
  155. function onDisplayOptions() {
  156.   setTimer(0);
  157.   ("Inventory_Window").modal = false;
  158.   ("Inventory_Window").active = false;
  159.   ("Inventory_Scroll").modal = false;
  160.   ("Inventory_Scroll").active = false;
  161.   temp.slot = this.cell_selected;
  162.  
  163.   if (temp.slot <= this.items.size()) {
  164.     play("necro_click2.wav");
  165.     temp.itemName = makevar("clientr.items"@ thiso.backpack)[slot];
  166.     if ( temp.itemName == NULL ) return;
  167.   }
  168.   if ( isObject("ItemOptions_Menu") ) {
  169.     ItemOptions_Menu.destroy();
  170.   }
  171.   new GuiContextMenuCtrl("ItemOptions_Menu") {
  172.     profile = "Necro_TextEdit";
  173.     useownprofile = true;
  174.     profile.modal = true;
  175.     profile.active = true;
  176.     profile.cankeyfocus = true;
  177.     profile.canstealfocus = true;
  178.     profile.makefirstresponder = true;
  179.     textprofile = "Necro_Text";
  180.     text = "Options";
  181.     width = 20;
  182.    
  183.     clearRows();
  184.    
  185.     addRow(0, "Options");
  186.     addrow(-1, "-");
  187.     for (temp.I = 0; temp.I < thiso.options.size(); temp.I++)
  188.     {
  189.       addRow(temp.I + 1, thiso.options[temp.I]);
  190.     }
  191.      
  192.     open(mousescreenx, mousescreeny);
  193.   }
  194.   ("ItemOptions_Menu").modal = true;
  195.   ("ItemOptions_Menu").active = true;
  196. }
  197.  
  198. function Options_Menu.onSelect(entryid, text)  {
  199.   temp.slot = this.cell_selected;
  200.  
  201.   if (temp.slot <= this.items.size()) {
  202.     play("necro_click2.wav");
  203.     temp.itemName = makevar("clientr.items"@ thiso.backpack)[slot];
  204.     temp.itemRealName = makevar("clientr.item_"@ temp.itemName)[1];
  205.     if ( temp.itemName == NULL ) {
  206.       if ( isObject("ItemOptions_Menu") )
  207.         ItemOptions_Menu.destroy();
  208.       return;
  209.     }
  210.   }
  211.   switch (text)  {  
  212.     case "Equip": {
  213.       player.chat = "Equip"SPC temp.itemRealName @"!";
  214.       break;
  215.     }
  216.     case "Drop": {
  217.       player.chat = "Drop"SPC temp.itemRealName @"!";
  218.       break;
  219.     }
  220.     case "Destroy": {
  221.       player.chat = "Destroy"SPC temp.itemRealName @"!";
  222.       break;
  223.     }
  224.   }
  225.   ("ItemOptions_Menu").modal = false;
  226.   ("ItemOptions_Menu").active = false;
  227.   ("Inventory_Window").modal = true;
  228.   ("Inventory_Window").active = true;
  229.   ("Inventory_Scroll").modal = true;
  230.   ("Inventory_Scroll").active = true;
  231.   setTimer(0.05);
  232. }
Advertisement
Add Comment
Please, Sign In to add comment