Cube  Diff

Differences From Artifact [c38d6c5a56]:

To Artifact [abea91099d]:


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
	if ((vmenu = menu) >= 1)
		[Player.player1 resetMovement];
	if (vmenu == 1)
		menus[1].menusel = 0;
}

COMMAND(showmenu, ARG_1STR, ^(OFString *name) {
	int i = 0;
	for (Menu *menu in menus) {
		if (i > 1 && [menu.name isEqual:name]) {
			menuset(i);
			return;
		}
		i++;
	}
})








|


|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
	if ((vmenu = menu) >= 1)
		[Player.player1 resetMovement];
	if (vmenu == 1)
		menus[1].menusel = 0;
}

COMMAND(showmenu, ARG_1STR, ^ (OFString *name) {
	int i = 0;
	for (Menu *menu in menus) {
		if (i > 1 && [menu.name isEqual: name]) {
			menuset(i);
			return;
		}
		i++;
	}
})

50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

	if (vmenu == 1)
		refreshservers();

	Menu *m = menus[vmenu];
	OFString *title;
	if (vmenu > 1)
		title = [OFString stringWithFormat:@"[ %@ menu ]", m.name];
	else
		title = m.name;
	int mdisp = m.items.count;
	int w = 0;
	for (int i = 0; i < mdisp; i++) {
		int x = text_width(m.items[i].text);
		if (x > w)







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

	if (vmenu == 1)
		refreshservers();

	Menu *m = menus[vmenu];
	OFString *title;
	if (vmenu > 1)
		title = [OFString stringWithFormat: @"[ %@ menu ]", m.name];
	else
		title = m.name;
	int mdisp = m.items.count;
	int w = 0;
	for (int i = 0; i < mdisp; i++) {
		int x = text_width(m.items[i].text);
		if (x > w)
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

void
newmenu(OFString *name)
{
	if (menus == nil)
		menus = [[OFMutableArray alloc] init];

	[menus addObject:[Menu menuWithName:name]];
}

COMMAND(newmenu, ARG_1STR, ^(OFString *name) {
	newmenu(name);
})

void
menumanual(int m, int n, OFString *text)
{
	if (n == 0)
		[menus[m].items removeAllObjects];

	MenuItem *item = [MenuItem itemWithText:text action:@""];
	[menus[m].items addObject:item];
}

COMMAND(menuitem, ARG_2STR, ^(OFString *text, OFString *action) {
	Menu *menu = menus.lastObject;

	MenuItem *item =
	    [MenuItem itemWithText:text
	                    action:(action.length > 0 ? action : text)];
	[menu.items addObject:item];
})

bool
menukey(int code, bool isdown)
{
	if (vmenu <= 0)
		return false;







|


|









|
|


|


|
|
|
|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

void
newmenu(OFString *name)
{
	if (menus == nil)
		menus = [[OFMutableArray alloc] init];

	[menus addObject: [Menu menuWithName: name]];
}

COMMAND(newmenu, ARG_1STR, ^ (OFString *name) {
	newmenu(name);
})

void
menumanual(int m, int n, OFString *text)
{
	if (n == 0)
		[menus[m].items removeAllObjects];

	MenuItem *item = [MenuItem itemWithText: text action: @""];
	[menus[m].items addObject: item];
}

COMMAND(menuitem, ARG_2STR, ^ (OFString *text, OFString *action) {
	Menu *menu = menus.lastObject;

	MenuItem *item = [MenuItem
	    itemWithText: text
		  action: (action.length > 0 ? action : text)];
	[menu.items addObject: item];
})

bool
menukey(int code, bool isdown)
{
	if (vmenu <= 0)
		return false;
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
			OFString *action = menus[vmenu].items[menusel].action;
			if (vmenu == 1)
				connects(getservername(menusel));

			if (menuStack == nil)
				menuStack = [[OFMutableArray alloc] init];

			[menuStack addObject:@(vmenu)];
			menuset(-1);

			execute(action, true);
		}
	}

	return true;
}







|








151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
			OFString *action = menus[vmenu].items[menusel].action;
			if (vmenu == 1)
				connects(getservername(menusel));

			if (menuStack == nil)
				menuStack = [[OFMutableArray alloc] init];

			[menuStack addObject: @(vmenu)];
			menuset(-1);

			execute(action, true);
		}
	}

	return true;
}