More reduction of reliance on hard-coded limits

This commit is contained in:
2015-02-07 09:46:51 -05:00
parent 6d26d430b3
commit f5a43bc011
11 changed files with 43 additions and 45 deletions

View File

@@ -107,13 +107,14 @@ void menu_activate() {
void update_item_menu() {
id targ = [[file_menu itemAtIndex: 0] target];
auto& item_list = univ.scenario.scen_items;
int per_menu = item_list.size() / 4;
for(int j = 0; j < 4; j++){
[items_menu[j] removeAllItems];
if(!scen_items_loaded) {
[[items_menu[j] addItemWithTitle: @"Items Not Loaded" action: @selector(itemMenu:) keyEquivalent: @""] setEnabled: NO];
} else for(int i = 0; i < 100; i++) {
ItemWrapper* item = [ItemWrapper withItem: i + 100 * j];
NSString* item_name = [NSString stringWithCString: item_list[i + j * 100].full_name.c_str() encoding: NSASCIIStringEncoding];
} else for(int i = 0; i < per_menu; i++) {
ItemWrapper* item = [ItemWrapper withItem: i + per_menu * j];
NSString* item_name = [NSString stringWithCString: item_list[i + j * per_menu].full_name.c_str() encoding: NSASCIIStringEncoding];
NSMenuItem* choice = [items_menu[j] addItemWithTitle: item_name action: @selector(itemMenu:) keyEquivalent: @""];
[choice setTarget: targ];
// TODO: Also disable gold or food